Crontab: 定时执行带参数脚本 - 完整指南
To schedule the execution of a script with arguments using `crontab`, you need to add an entry to the crontab file. Here's how you can do it:\n\n1. Open the crontab file for editing by running the command:\n \n crontab -e\n \n\n2. In the crontab file, add a new line with the schedule and the command to execute the script. For example, to run the script every day at 8:00 AM and pass an argument to the script, you can use the following syntax:\n \n 0 8 * * * /path/to/script.sh argument\n \n\n Explanation of the schedule format:\n - The first field represents the minute (0-59).\n - The second field represents the hour (0-23).\n - The third field represents the day of the month (1-31).\n - The fourth field represents the month (1-12).\n - The fifth field represents the day of the week (0-7, where both 0 and 7 represent Sunday).\n\n3. Replace `/path/to/script.sh` with the actual path to your script.\n4. Replace `argument` with the argument you want to pass to the script.\n\n5. Save the crontab file and exit the editor.\n\nThe script will now be scheduled to run with the specified argument at the specified time.
原文地址: https://www.cveoy.top/t/topic/p87C 著作权归作者所有。请勿转载和采集!