Use crontab under ubuntu

Create crontab task

Reference: https://www.cnblogs.com/Icanflyssj/p/5138851.html

3. Several command formats commonly used by crontab

crontab -l //Display the contents of the user's crontab file

crontab -e //edit the contents of the user's crontab file

crontab -r //delete the user's crontab file

-------

When using crontab -e for the first time, you will be asked to select an editor, I chose vim.basic

Edit the file, the content is as follows

root@ubuntu:/var/log# crontab -e
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
* * * * * /home/xwdreamer/eclipse-workspace/RELEASED_V2_10_20180331/iotkit-embedded/output/release/bin/linkkit-example

 

 

 

log service

Reference: https://blog.csdn.net/ggz631047367/article/details/50185425

Ubuntu does not open cron logging by default 
1. Modify rsyslog 
sudo vim /etc/rsyslog.d/50-default.conf 
cron.* /var/log/cron.log #Remove the comment before cron 
2. Restart rsyslog 
sudo service rsyslog restart 
3. Check crontab log 
less /var/log/cron.log

Note: The log service must be restarted here. After restarting, use less to view there may be no logs, and you need to wait for the task to be executed before you can see the logs.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325127848&siteId=291194637