CentOS 7 Crontab: Setup & Manage Tasks
In CentOS 7, you can use the crontab command to set and manage scheduled tasks. Here are some common actions:
- View the list of scheduled tasks for the current user.
crontab -l
- Edit the current user’s scheduled tasks list:
crontab -e
This will open a text editor where you can add, modify, or delete scheduled tasks. The format for scheduled tasks is: minute hour day month week command to be executed.
- Delete the current user’s list of scheduled tasks:
crontab -r
- View the scheduled task list of all users in the system.
ls /var/spool/cron/
- Edit the scheduled task list of other users.
crontab -u username -e
The username is the name of the user that needs to be edited.
- 重启cron服务:
systemctl restart crond
By following the above steps, you can easily set up and manage scheduled tasks.