Linux Cron Job Setup Tutorial
To set up a cron scheduled task, you can follow these steps:
- Open the terminal and enter the following command to edit the cron schedule task list:
crontab -e
- In the opened file, add the configuration for the tasks you want to execute. The format for each line is: minute hour day month day_of_week command. For example, to run a script every day at 9 AM, you can add the following content:
0 9 * * * /path/to/your/script.sh
- Save and exit the file. You can press Ctrl + X, then press Y to save the changes.
- You can use the following command to view the current list of cron scheduled tasks:
crontab -l
- If you wish to remove all cron scheduled tasks, you can use the following command:
crontab -r
- To view the log information of the cron service, you can enter the following command in the terminal:
sudo cat /var/log/syslog | grep cron
This completes the process of configuring cron scheduled tasks in Linux. You can add, modify, or delete scheduled tasks as needed to automatically carry out your tasks.