Referring to the page:
http://qiita.com/katsukii/items/d5f90a6e4592d1414f99
Checking the crontab
Deleting crontab
Checking the logs of cron
http://qiita.com/katsukii/items/d5f90a6e4592d1414f99
Step1: Checking Daemon
[root@ip-172-31-27-217 cron]# service crond status
crond (pid 1306) is running...
Step2: Editting shell: date command and ping 8.8.8.8 and write the outputs into hoge.txt
[root@ip-172-31-27-217 ~]# more ping.sh
date >> hoge.txt;
ping -c 1 8.8.8.8 | grep 'from' >> hoge.txt
Step3. Editting crontab
[root@ip-172-31-27-217 ~]# crontab -e
*/10 * * * * cd /root; ./ping.sh
Result
[root@ip-172-31-27-217 ~]# more hoge.txt
Mon Oct 31 03:20:01 EDT 2016
64 bytes from 8.8.8.8: icmp_seq=1 ttl=59 time=3.53 ms
Mon Oct 31 03:30:01 EDT 2016
64 bytes from 8.8.8.8: icmp_seq=1 ttl=59 time=3.51 ms
Mon Oct 31 03:40:01 EDT 2016
64 bytes from 8.8.8.8: icmp_seq=1 ttl=59 time=3.60 ms
Mon Oct 31 03:50:01 EDT 2016
64 bytes from 8.8.8.8: icmp_seq=1 ttl=59 time=3.54 ms
Checking the crontab
[root@ip-172-31-27-217 ~]# crontab -l
*/10 * * * * cd /root; ./ping.sh
[root@ip-172-31-27-217 ~]# crontab -r
Checking the logs of cron
[root@ip-172-31-27-217 ~]# more /var/log/cron
<snip>
Oct 31 03:20:01 ip-172-31-27-217 CROND[5316]: (root) CMD (cd /root; ./ping.sh)
Oct 31 03:20:01 ip-172-31-27-217 CROND[5315]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 31 03:30:01 ip-172-31-27-217 CROND[5343]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 31 03:30:01 ip-172-31-27-217 CROND[5344]: (root) CMD (cd /root; ./ping.sh)
Oct 31 03:37:02 ip-172-31-27-217 anacron[2426]: Job `cron.weekly' started
Oct 31 03:37:02 ip-172-31-27-217 anacron[2426]: Job `cron.weekly' terminated
Oct 31 03:40:01 ip-172-31-27-217 CROND[5389]: (root) CMD (cd /root; ./ping.sh)
Oct 31 03:40:01 ip-172-31-27-217 CROND[5390]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 31 03:50:01 ip-172-31-27-217 CROND[5415]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Oct 31 03:50:01 ip-172-31-27-217 CROND[5416]: (root) CMD (cd /root; ./ping.sh)
Oct 31 03:55:34 ip-172-31-27-217 crontab[5430]: (root) BEGIN EDIT (root)
Comments
Post a Comment