How strong is chatgpt setting automated tasks in 10 seconds

From 清冽之泉
Jump to navigation Jump to search
How to write a corntab to run sth.sh at everyday 21:30?
ChatGPT

To schedule a task to run a shell script (sth.sh) every day at 21:30 using a cron job, you can create a cron tab entry. Cron tab entries have the following format:

* * * * * command_to_be_executed
- - - - -
| | | | |
| | | | +----- Day of the week (0 - 7) (Sunday is both 0 and 7)
| | | +------- Month (1 - 12)
| | +--------- Day of the month (1 - 31)
| +----------- Hour (0 - 23)
+------------- Minute (0 - 59)

To run sth.sh every day at 21:30, you would set the minute field to 30 and the hour field to 21. The other fields can be set to an asterisk (*) to indicate "any" value. Here's the cron tab entry to achieve this:

30 21 * * * /path/to/sth.sh

Make sure to replace /path/to/sth.sh with the actual path to your sth.sh script. To edit your crontab, you can use the crontab -e command, which opens your default text editor for editing the cron jobs. Add the line mentioned above to schedule your script to run at 21:30 every day, and then save the file.

Remember that the timing of cron jobs is based on your system's local time, so ensure that your system's clock and time zone settings are accurate.

另外,编辑定时任务的命令: crontab -e ,查看定时任务 crontab -l