What is the method for setting up scheduled tasks in Linux?
In a Linux system, you can schedule tasks using the crontab command.
- Open the terminal and type the following command to edit the scheduled task list for the current user:
crontab -e
- Add scheduled tasks in the editor, one per line, following this format:
* * * * * command
Each asterisk represents a unit of time, in the order of minutes, hours, dates, months, and days of the week, with the command being the action to be executed.
- Save and exit the editor, the cron job will automatically take effect, and the scheduled tasks will be executed according to the set time period.
- To view the current user’s list of scheduled tasks, you can use the following command:
crontab -l
- To remove all scheduled tasks for the current user, you can use the following command:
crontab -r