Skip to main content

cron/crontab

Referring to the page:
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

Deleting crontab
[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

Popular posts from this blog

SNMP mib file installation

Step1: Installing private MIB file and changing SNMP configuration on PC Refeering to the following link for private mibs: http://changineer.info/server/monitoring/monitoring_snmp.html http://wiki.pomme-tech.com/index.cgi?page=%A5%D7%A5%E9%A5%A4%A5%D9%A1%BC%A5%C8MIB%A4%CE%C4%C9%B2%C3&print=1 http://www.lesstep.jp/step_on_board/linux/23/ Refeering to the following link for errors related to mibs: http://www.zabbix.jp/node/3056 http://serverfault.com/questions/440319/did-not-find-zerodotzero-in-module-snmpv2-smi Step2. installing private mib files in an appropriate directory(/usr/share/snmp/private-bims) Step3. changing snmp.conf files. You may need to create an empty new file NOT snmpd.conf. ---------------------------------------- /etc/snmp/snmp.conf MIBDIRS /usr/share/snmp/mibs:/usr/share/snmp/private-bims MIBS all ---------------------------------------- Step4: Checking the output before and after installing private mib files. You don't need to restart th

SNMP mib tips: snmpwalk & snmptranslate

Referring to this web site: https://gist.github.com/bahootyper/575190 The following explanations are about snmpwalk & snmptranslate command options. #Displayes every OID $ snmptranslate -Tp #Dispaly OID label(MIB name) from OID $ snmptranslate .1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2 WLSX-SWITCH-MIB::userPhyAddress #Dispaly MIB tree name from OID label #-IR: label,  -Tp: tree option $ snmptranslate -IR -Tp nUser6Name +-- -R-- String    nUser6Name(3)          Textual Convention: DisplayString          Size: 0..128 #Dispaly MIB tree name from OID label #-IR: label,  -Tp: tree option $ snmptranslate -Tp .1.3.6.1.4.1.14823.2.2.1.14.1.2.1.3 +-- -R-- String    nUser6Name(3)          Textual Convention: DisplayString          Size: 0..128 # OID's detailed option $ snmptranslate -Td .1.3.6.1.4.1.14823.2.2.1.14.1.2.1.3 WLSX-USER6-MIB::nUser6Name nUser6Name OBJECT-TYPE   -- FROM WLSX-USER6-MIB   -- TEXTUAL CONVENTION DisplayString   SYNTAX OCTET STRING (0..1

ettercap on MAC OSX

TK-MBA-2:~ taka$ brew info ettercap ettercap: stable 0.8.2 (bottled), HEAD Multipurpose sniffer/interceptor/logger for switched LAN https://ettercap.github.io/ettercap/ /usr/local/Cellar/ettercap/0.8.2_1 (75 files, 2.3MB) *   Poured from bottle on 2017-05-25 at 14:14:48 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ettercap.rb ==> Dependencies Build: cmake ✘ , ghostscript ✘ Required: pcre ✔ , libnet ✔ , openssl ✔ Optional: ghostscript ✘ , gtk+ ✘ , gtk+3 ✘ , luajit ✘ ==> Options --with-ghostscript Build with ghostscript support --with-gtk+ Build with gtk+ support --with-gtk+3 Build with gtk+3 support --with-luajit Build with luajit support --without-curses Install without curses interface --without-ipv6 Install without IPv6 support --without-plugins Install without plugins support --HEAD Install HEAD version TK-MBA-2:~ taka$ ettercap --with-gtk+ ettercap 0.8.2 copyright 2001-2015 Ettercap