Step by step for crontab stop setup 
Sea@sea:/etc/lazada$ sudo crontab -e
1.Edit cron job
0 */6 * * * curl -X POST -d @/etc/lzd/lzd_tracking.txt  http://localhost:8080/booking/rs/LzdService/post --header "Content-Type:application/json"
Chnage it like :
#0 */6 * * * curl -X POST -d @/etc/lzd/lzd_tracking.txt  http://localhost:8080/booking/rs/LzdService/post --header "Content-Type:application/json"

2.restart cron job
Sea@sea:/etc/lazada$ sudo /etc/init.d/cron reload
Sea@sea:/etc/lazada$ sudo /etc/init.d/cron restart
3.check crontab if succeed start
Sea@sea:/etc/lazada$ sudo ps -ef| grep cron
root     30871     1  0 12:22 ?        00:00:00 cron

 

/etc/lazada/lazada_tracking.txt   json 数据--> 用于post 



crontab ubuntu16.04 基本使用:
ubuntu安装cron(默认有安装)
安装:apt-get install cron
启动:service cron start
重启:service cron restart
停止:service cron stop
检查状态:service cron status
查询cron可用的命令:service cron
检查Cronta工具是否安装:crontab -l

来打开你的用户所属的crontab文件。第一次用这个命令,会让你选择文本编辑器,我选的是vim。选定的编辑器也可以使用
select-editor 

命令来更改。选择vim 

#编辑
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
#*/1 * * * * date >> /home/sea/Desktop/baxiancode/mytest.log
0 2 * * * /home/sea/Desktop/baxiancode/start_daily_tops_service/start_daily_tops_service.sh
#*/30 * * * * nohup  /home/sea/Desktop/MyShop/shopmonitor/shopmonitor/shopmonitor/start_shop_monitor.sh >> /home/sea/Desktop/baxiancode/shopmonitor.log 2>&1 &
*/30 * * * * nohup  /home/sea/Desktop/MyShop/shopmonitor/shopitemmonitor/shopitemmonitor/start_shop_item_monitor.sh >> /home/sea/Desktop/baxiancode/shop_item_monitor.log 2>&1 &

保存了crontab之后,我们还需要重启cron来应用这个计划任务。使用以下命令:

sudo service cron restart

crontab -l   命令列出它的全部信息

crontab 在线测试:https://www.matools.com/crontab

crontab 每分钟、每小时、每天、每周、每月、每年定时执行

crontab时间格式说明
        minute(分)可以设置0-59分
        hour(小时)可以设置0-23小时
        day of month(日期)可以设置1-31号
        month(月份):可以设置1-12月
        day of week(星期):可以设置0-7星期几,其中0和7都代表星期天,或者我们也可以使用名称来表示星期天到星期一,例如sun表示星期天,mon表示星期一等等
crontab范例
    每五分钟执行          */5 * * * *
    每小时执行            0 * * * *
    每天执行                  0 0 * * *
    每周日00:00:00执行        0 0 * * 0
    每月1号,0零点执行       0 0 1 * *
  每年执行              0 0 1 1 *

 

crontab 范例:

0 1 * * 1   每周一,1:00 AM 执行一次 2021-10-04 01:00:00

0 2 1 * *       每月1号,2点执行 2021-10-01 02:00:00

 

posted on 2020-01-17 18:46  lshan  阅读(316)  评论(0编辑  收藏  举报