Crontab job is not working


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Crontab job is not working
# 1  
Old 03-04-2016
Crontab job is not working

hell all:


i am trying to test a crontab job for snmpwalk but it is not working:


here is crontab:
Code:
*/1    *    *    *    *    root    /root/snmpwalk.sh




for the script, it is very simple:


Code:
#!/usr/local/bin/bash

/usr/local/bin/snmpwalk -v 2c -c public 100.10.10.10


from the log, i can see this
Code:
Mar  4 15:22:00 snails /usr/sbin/cron[88515]: (operator) CMD (/usr/libexec/save-entropy)
Mar  4 15:22:00 snails /usr/sbin/cron[88516]: (root) CMD (root^I/root/snmpwalk.sh)
Mar  4 15:23:00 snails /usr/sbin/cron[88531]: (root) CMD (root^I/root/snmpwalk.sh)
Mar  4 15:24:00 snails /usr/sbin/cron[88534]: (root) CMD (root^I/root/snmpwalk.sh)



thanks.



_dave

Last edited by Don Cragun; 03-04-2016 at 11:31 PM.. Reason: Add CODE tags.
# 2  
Old 03-04-2016
I don't know what the root command on your system does. And, I don't see from the details you have given us why you believe something is wrong.

The log shows that over a period of three minutes, cron ran the command:
Code:
root	/root/snmpwalk.sh

three times as requested.

What else happened that you didn't expect to happen? What didn't happen that you expected to happen?
# 3  
Old 03-05-2016
Quote:
Originally Posted by Don Cragun
I don't know what the root command on your system does. And, I don't see from the details you have given us why you believe something is wrong.

The log shows that over a period of three minutes, cron ran the command:
Code:
root    /root/snmpwalk.sh

three times as requested.

What else happened that you didn't expect to happen? What didn't happen that you expected to happen?

thanks don:

all i want to do is to execute follow command every minute:

Code:
/usr/local/bin/snmpwalk -v 2c -c public 100.10.10.10

i thought crontab job should do it. actually i removed that user "root", instead here

Code:
*/1    *    *    *    *    /root/snmpwalk.sh

it still not doing i expected.

so i ran this test manually and it worked fine:

Code:
/usr/local/bin/bash /root/snmpwalk.sh

---------- Post updated 03-05-16 at 12:05 AM ---------- Previous update was 03-04-16 at 11:14 PM ----------

thanks don:

typo... sorry.

Last edited by ipfreak; 03-05-2016 at 12:22 AM..
# 4  
Old 03-05-2016
What output do you get from the commands:
Code:
ls -l /root/snmpwalk.sh;cat /root/snmpwalk.sh

And, what happens if you just put the line:
Code:
*/1    *    *    *    *    /usr/local/bin/snmpwalk -v 2c -c public 100.10.10.10

or the line:
Code:
*/1    *    *    *    *    /usr/local/bin/bash /root/snmpwalk.sh

in root's crontab file?
# 5  
Old 03-05-2016
I don't know how the command snmpwalk is managed internally within the OS so I would ask the question whether there are any implications if when the cron job is triggered the previous run hasn't finished; i.e. the command takes over one minute to run?

Would that cause any adverse effects? I just dunno whether there would be any open/locked files/interfaces.

Last edited by hicksd8; 03-05-2016 at 02:50 PM..
# 6  
Old 03-05-2016
Does your cron understand the */1?
Otherwise use *.
# 7  
Old 03-06-2016
Do you have the cron log for the modified entry in the crontab?

Just as MadeInGermany said, */1 is nothing but *
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Crontab - entry not working , cron job not running

I have put a cron entry in oracle user for taking hot backup every wednesday@ 2.30 AM and have given the cron entry 30 02 * * 3 /u01/vijay/hotbackupcron 2>&1 >> /u01/vijay/hotbackup.log also find below the script inside hotbackupcron, i have put in env variables as well ... (13 Replies)
Discussion started by: vijaymec50
13 Replies

2. SuSE

A crontab job not working

Hello, This is my first posting in Linux world. I have SLES 11. I've created a file 'packdisk-scandisk.txt' file under /var/opt/Teradata/bteqdba. The content of the file is, cat /var/opt/Teradata/bteqdba/packdisk-scandisk.txt output over /var/opt/Teradata/bteqdba/TAREAS_DBA.log... (2 Replies)
Discussion started by: JDBA
2 Replies

3. Shell Programming and Scripting

Crontab Job Syntax

I have a ksh script that does the following 1. Script executes and creates an output file from a sql query 2. That output file is an input file to the script 3. generates an html file to email to DBA receipients The following syntax works at the command line ... (1 Reply)
Discussion started by: JolietJake
1 Replies

4. Shell Programming and Scripting

Crontab Job Output File

I am a newbie to Unix. My default root user umask is set to 077 and I have the following crontab job to redirect al the backup output to the logfile of /backup/backup.xxxxx 00 10 * * 0 /usr/local/bin/backup.sh > /backup/backup.`date +\%Y\%m\%d` 2>&1 Since root default umask is 077, the... (2 Replies)
Discussion started by: famasutika
2 Replies

5. Shell Programming and Scripting

crontab job not executed with variables

Hi, I am trying to execute a script (for once) during the booting time in Ubuntu system. However, the result is only showing the strings without without the variables. Here is the script: MgrIp=$(ec2-describe-instances --filter tag:Name=Mgr --filter instance-state-name=running | egrep... (4 Replies)
Discussion started by: turki_00
4 Replies

6. Shell Programming and Scripting

Schedule a job using Crontab

I would like to execute my script at 17.30 and 23.00 using crontab, could anybody help me out!! Thanks in Advance!! (1 Reply)
Discussion started by: jatanig
1 Replies

7. UNIX for Dummies Questions & Answers

crontab job not running

Hi all, down here part of the scheduled job in crontab (AIX Version 5) i have problem running jspPRE-ALL. i verrify permissions and privileges (the others job are working good) if i run the job in command line it work correctly # # Aggiornamento doni e continuity 00 02 * * 2-6... (5 Replies)
Discussion started by: ilpasta
5 Replies

8. Shell Programming and Scripting

Help with a crontab job!!!

Hi, i need to schedule a script to run at 6.10AM everyday.I tried to do this way. #!bin/ksh 10 06 * * 0-6 sh /tmp/ss/script/daily_file_check.sh And at the command prompt I did >crontab -e cron.txt I'm not sure whether this is the right way. Can anyone please tell me how to... (4 Replies)
Discussion started by: kumarsaravana_s
4 Replies

9. UNIX for Dummies Questions & Answers

Crontab job queue

My cronjob triggers the script late by 6 minutes. /var/cron/log shows that it got triggered at the right time then where can I track, the late starting of the script. Is there some queue mechanism, some log? This happens sometimes, not daily. but it affects me, whenever it happens. Logging... (1 Reply)
Discussion started by: pksingh2
1 Replies

10. UNIX for Dummies Questions & Answers

crontab job

Hi, I have cornjob was scheduled at 1:00 AM everyday. It has been running fine since last Saturday. But it didn't run since Saturday. Because of daytime saving time change it didn't ran? Please send me your thoughts. Thanks in adavance. Moe (3 Replies)
Discussion started by: Moe
3 Replies
Login or Register to Ask a Question