ubuntu crontab创建定时任务

1.添加定时任务并保存
  hadoop@hadoopSlave2:/opt/shell$ crontab -e 
  添加:47 12 * * * /opt/shell/showDate.sh >> /opt/shell/hello.log
2.重启cron进程
  hadoop@hadoopSlave2:/opt/shell$ service cron restart/stop/start
  stop: Rejected send message, 1 matched rules; type="method_call",
  sender=":1.83" (uid=1000 pid=32646 comm="stop cron ") interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.84" (uid=1000 pid=32643 comm="start cron ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
3.查看crontab服务是否启动
  hadoop@hadoopSlave2:/opt/shell$ service cron status
  cron start/running, process 989

4.查看已经存在的定时任务
  hadoop@hadoopSlave2:/opt/shell$ crontab -l
  47 12 * * * /opt/shell/showDate.sh >> /opt/shell/hello.log
5.hadoop@hadoopSlave2:/opt/shell$ vim showDate.sh 
  #!/bin/bash
  date +%A
6.删除  
  hadoop@hadoopSlave2:/opt/shell$ crontab -r
  hadoop@hadoopSlave2:/opt/shell$ crontab -l
  no crontab for hadoop

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值