cron创建定时任务

本文介绍 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创建定时任务需要如下步骤:

  1. 首先得把cron的log打开,不然你看不到log

    sudo vim /etc/rsyslog.d/50-default.conf
    

    把cron.*那一行注释去掉。

    然后重启rsys:

    sudo services rsyslog restart
    
  2. 编写你的脚本sh,并将它放到一个目录下:

    # 比如 /root/crontabs/cron_run_lidar.sh
    
    crontab -e
    
    编辑加入:
    
    10 22 * * * (/bin/sh /root/crontabs/cron_run_lidar.sh)
    表示,每天的22:10,执行那个sh脚本文件。
    

接着就可以了。查看任务用 crontab -l.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值