Regularly use crontab to perform tasks under Linux (Ubuntu) system

 

Installation cron (Ubuntu system comes)

apt-get install cron

 

Open crontab log

Log in default is not open, we need to find # cron /etc/rsyslog.d/50-default.conf files. *, The # comment deleted signature

You can use vim to edit files, Reference  Vim Start Basics

After editing, restart the rsyslog service

service rsyslog restart;

Restart crontab Service

service cron restart;

 

A brief presentation

First, we create a new file

/tmp/time.txt

(Can be created using vim editor)

vim /tmp/time.txt

 

Write a timed task

crontab -e

PS:
Every minute * * * * * 
executed every five minutes * / 5 * * * * 
every hour 0 * * * * 
execution day 00 * * *  execution * * 0 0 0 weekly  monthly execution * 001 * implementation of 0011 per year *

In the last insert a new row

* * * * * date >> /tmp/time.txt

(Per minute write the current time to the target file)

 

Restart service wait a bit to see the results

cat /tmp/time.txt

3 , Cron Jobs list is displayed 

using the following command to list the current user cron jobs plan. 

crontab - L 


If you want to see other user's cron job, you can use the following command (which lists the specified user cron job): 

crontab the -l -u username

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/yiduobaozhiblog1/p/11933518.html