本文介绍 cron创建定时任务
cron创建定时任务
This article was original written by XRBLS, welcome re-post, first come with https://jinfagang.github.io . but please keep this copyright info, thanks, any question could be asked via wechat:
jintianiloveu
cron是linux自带的一个定时任务管理器,通过cron创建定时任务需要如下步骤:
-
首先得把cron的log打开,不然你看不到log
sudo vim /etc/rsyslog.d/50-default.conf
把cron.*那一行注释去掉。
然后重启rsys:
sudo services rsyslog restart
-
编写你的脚本sh,并将它放到一个目录下:
# 比如 /root/crontabs/cron_run_lidar.sh crontab -e 编辑加入: 10 22 * * * (/bin/sh /root/crontabs/cron_run_lidar.sh) 表示,每天的22:10,执行那个sh脚本文件。
接着就可以了。查看任务用 crontab -l
.