Linux task planning tool crontab

  
        

crontab can periodically perform the actions you want to do

Edit directly with crontab command

crontab -u //Set a user's cron service, generally the root user is executing this This parameter is required for the command

crontab -l //list the details of a user cron service

crontab -r //delete a user's cron service

crontab -e //Edit a user's cron service

Generally use crontab -e to edit a plan action, the edit mode is the same as the vi editor

The basic editing format in crontab is as follows

* * * * * command

Time-of-day day and month week command

Column 1 means minutes 1~59 per minute with * or */1

The second column indicates the hour 1~23 (0 means 0 point)

The third column indicates the date 1~31

The fourth column indicates the month 1~12

Column 5 identification number Week 0~6 (0 means Sunday)

Column 6 command to run

crontab Some examples of the pieces:

30 21 * * * /etc/init.d/smb restart

The above example means restarting smb every night at 21:30.

45 4 1,10,22 * * /etc/init.d/smb restart

The above example shows that 4:45 restarts smb on the 1, 10, 22, every month.

10 1 * * 6,0 /etc/init.d/smb restart

The above example shows restarting smb every Saturday and Sunday 1:10.

0,30 18-23 * * * /etc/init.d/smb restart

The above example shows that smb is restarted every 30 minutes between 18: 00 and 23:00 every day.

0 23 * * 6 /etc/init.d/smb restart

The above example shows restarting smb every Saturday at 11:00 pm.

0 */1 * * * /etc/init.d/Smb restart (Note: * */1 * * * /etc/init.d/smb restart This will be executed every minute)

Restart smb every hour

0 23 -7/1 * * * /etc/init.d/smb restart

Restart smb every hour between 11pm and 7am

0 11 4 * mon- Wed /etc/init.d/smb resta Rt

Restart smb at 11 o'clock every month and every Monday to Wednesday

0 4 1 jan * /etc/init.d/smb restart

January 4 o'clock on the 1st restart smb

Copyright © Windows knowledge All Rights Reserved