Operating System - HP-UX
1838622 Members
2013 Online
110128 Solutions
New Discussion

cronjob running with rc=1

 
SOLVED
Go to solution
boomer_2
Super Advisor

cronjob running with rc=1

Hi guys,
this is my cron entry to run every minas a root for testing,but its not working........
* * * * * /usr/bin/top -n3 -d1 >> /var/adm/toplog/top.txt > /dev/null 2>&1
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: cronjob running with rc=1

Shalom,

The job failed. return code 1 rc=1 means whatever the cron job tried to do failed to run.

I have a feeling it may be the syntax, try running it without the second > /dev/null.

I would do this:

/usr/contrib/bin/runtop

The script runtop can handle where the screen writes go.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Peter Nikitka
Honored Contributor

Re: cronjob running with rc=1

Hi,

are you shure you have write access to the output file /var/adm/toplog/top.txt ?
If not, an exit code <>0 would reflect that.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Pete Randall
Outstanding Contributor

Re: cronjob running with rc=1

The other main reason why cron jobs fail is because they are executed with a very minimal environment: very few variables are set and your PATH is minimal. Make sure that any variables you are referring to in the script are set and that you either specify full path names or set an appropriate PATH.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: cronjob running with rc=1

Hi:

Do you have write permissions to the directory --- '/var/adm/toplog'? Unless you are root, and then that's your problem.

Aside from that, you woun't capture any output with the multiple redirection of STDOUT. I think you want:

# /usr/bin/top -n3 -d1 >> /var/adm/toplog/top.txt 2>/dev/null

Regards!

...JRF...
Patrick Wallek
Honored Contributor
Solution

Re: cronjob running with rc=1

If you are wanting to write top output to a file you can use the '-f filename' switch for top. If the file exists, the data will be appended.

Try this for your top command:

/usr/bin/top -n3 -d1 -f /var/adm/toplog/top.txt > /dev/null 2>&1
boomer_2
Super Advisor

Re: cronjob running with rc=1

Ok guys,
I will try this out tomorrow...and let u know tomorrow...Only then points would be given....bye 4 now...