Cron job not working but works on other nodes.


 
Thread Tools Search this Thread
Operating Systems AIX Cron job not working but works on other nodes.
# 1  
Old 12-26-2013
IBM Cron job not working but works on other nodes.

Hi All,

I have a many cron jobs scheduled in my AIX server.
Only one cron not getting executed in the same server but that job is good on all other servers.

Here is my cron , which will keep last 30 files and remove others.,
Code:
00 00 * * * /usr/bin/find /tmp/reports/nmon -name  *.nmon -mtime +30 -exec rm {} \\;

Note: The scripts works if executed manually.

Please Help me out!

Last edited by Franklin52; 12-26-2013 at 06:55 AM.. Reason: Please use code tags
# 2  
Old 12-26-2013
try redirecting the cron entry to a log and see if any error is being captured .
# 3  
Old 12-26-2013
Zozoo,

I tired but the log file is empty
Code:
55 15 * * * /usr/bin/find /tmp/reports/nmon -name  *.nmon -mtime +30 -exec rm {} \\ >> mybug.log

if i manually execute this command i am able to find the files
Code:
/usr/bin/find /tmp/reports/nmon -name  *.nmon -mtime +30

Any suggestion?

Last edited by Franklin52; 12-26-2013 at 06:55 AM.. Reason: Please use code tags
# 4  
Old 12-26-2013
Hello Thala,

Could you please try to put the code in a script and then try to put it in Cron tab.


Thanks,
R. Singh
# 5  
Old 12-26-2013
try giving the
Code:
2>&1

to capture the error and also ...can you try to enclose the whole command with in
Code:
()

---------- Post updated at 07:42 PM ---------- Previous update was at 07:27 PM ----------

found some information which can be useful

cron will email you the output of any program it runs (if there is any output). So, if you don't get any output, there are basically three possibilities:

crond could not even start a shell for running the program or sending email
crond had troubles mailing the output, or the mail was lost.
the program did not produce any output (including error messages)

Case 1. is very unlikely, but something should have been written in the cron logs. Cron has an own reserved syslog facility, so you should have a look into /etc/syslog.conf (or the equivalent file in your distro) to see where messages of facility cron are sent. Popular destinations include
Code:
/var/log/cron, /var/log/messages

and
Code:
/var/log/syslog.

In case 2., you should inspect the mailer daemon logs: messages from the Cron daemon usually appear as from
Code:
root@yourhost

. You can use a
Code:
 MAILTO=...

line in the crontab file to have cron send email to a specific address, which should make it easier to grep the mailer daemon logs. For instance:

In case 3., you can test if the program was actually run by appending another command whose effect you can easily check: for instance,

Code:
00 15 * * * /a/command; touch /<some -path>/sucessfullrun

so you can check if crond has actually run something by looking at the mtime of /<some -path>/sucessfullrun
# 6  
Old 12-27-2013
I would suggest that the shell is expanding the *.nmon in the current directory before trying to execute the command.

Try this to pass the wild-card value straight through to the find command:-
Code:
55 15 * * * /usr/bin/find /tmp/reports/nmon -name  "*.nmon" -mtime +30 -exec rm {} \; >> mybug.log 2>&1

I have corrected the \\ into \; and captured the errors too.

Of course, you are assuming that it is being called at all. Consider stoping your cron process. It should re-start and re-read your crontab file. You are editing the file with crontab -e aren't you? Changing the clock can also upset the cron process.


I hope that this helps.

Robin,
Liverpool/Blackburn
UK
# 7  
Old 12-28-2013
Hi Robin,
I tried your script its working fine manually again !
but when i execute in crontab, it is not executing ! and the log file is also empty.

Yes , i am using crontab -e , hope i dont need to refresh the cron as i was saving the file after editing though it will auto refresh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cron job not working

cron process in AIX is there when I do ps -ef |grep cron, but none of cron job is working. It appears that cron process is hanging or having some issues? How do you resolve this? Do I kill the cron process by kill -9 PID? and how to start it? Please advise. (1 Reply)
Discussion started by: Daniel Gate
1 Replies

2. Shell Programming and Scripting

cron job now working?

Hi all, I wrote a script as below, #!/bin/ksh . /app/home/etc/sudo.profile >/dev/null java -jar $HOME/abc.jar The jar file abc.jar is located in the same folder as the script. When I'm manually running that script the jar file gets executed. However if I set a cron job, it... (5 Replies)
Discussion started by: isaacniu
5 Replies

3. Shell Programming and Scripting

cron job is not working for two scripts

Hi Gurus, I have a test unix server in which currently some unix cronjob are running. I have written two script one is a shell script in which env variable are there (in that i am exporting those variables). I have also written a perl script . when i am running at the shell manually like... (5 Replies)
Discussion started by: sanjay.login
5 Replies

4. Shell Programming and Scripting

find cmd works different on cron job ?

/usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a -name '*.csv' \) -o -name '*_xyz_*' \) -mtime $DAYS_AGO -printf %f -printf "\n" | sort -r > $FILES The above command gives different results when run on a cron job. When run manually the result is accurate. (2 Replies)
Discussion started by: nuthalapati
2 Replies

5. Shell Programming and Scripting

Sudo command not working with cron job.

Hello, I have written a script that has a sudo command to change file permissions within it. When I run the script manually, the sudo command inside of it works fine. When the script is run through crontab I get the error "cron: not found". It the same user profile that I am using... (6 Replies)
Discussion started by: WhotheWhat
6 Replies

6. Shell Programming and Scripting

Cron job fails, but works fine from command line

I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is: 55 23 * * * /usr/bin/archive_logs The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously... (3 Replies)
Discussion started by: cdunavent
3 Replies

7. Shell Programming and Scripting

cron job not working for some reasons

I set up a new cron job. I have set cron jobs many times in the past and never faced issues. For some reasons my new cron job is not working.This is how my cron job looks like. plz help me out guys. 3,8,13,18,23,28,33,38,43,48,53,58 * * * * /siebel/sblp900/home/FSMTaskChk/script... (14 Replies)
Discussion started by: ragha81
14 Replies

8. UNIX for Dummies Questions & Answers

Cron job not working

Hello, I have the following crontab entry that does not seem to be running. When I check /var/cron/log, it is not there. Here is my os info: SunOS birch 5.9 Generic_118558-09 sun4u sparc SUNW,Sun-Fire-V240 Here is the crontab entry: 01 21 * * * find /export/app/datafeed/flus/archive -mtime... (5 Replies)
Discussion started by: dkranes
5 Replies

9. UNIX for Dummies Questions & Answers

script works on command line, not in cron job

Hey there, I'm a total newbie unix guy here and just picking this stuff up. Have a very small script I put together that works fine from the command line but not once I put it in a cron job. Searched and found this thread and am wondering it it has something to do with setting variables, though the... (7 Replies)
Discussion started by: JackTheTripper
7 Replies

10. Shell Programming and Scripting

Cron job not working

Hi All, I created a shell script and it works perfectly fine when I run from the command. But the same does not work as expected when I call it from a cron job. Here is the shell script(scan.sh): # # #Which directory to scan for files?... (7 Replies)
Discussion started by: janavenki
7 Replies
Login or Register to Ask a Question