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:

  1. View the list of scheduled tasks for the current user.
crontab -l
  1. 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.

  1. Delete the current user’s list of scheduled tasks:
crontab -r
  1. View the scheduled task list of all users in the system.
ls /var/spool/cron/
  1. 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.

  1. 重启cron服务:
systemctl restart crond

By following the above steps, you can easily set up and manage scheduled tasks.

bannerAds