1847791 Members
3354 Online
104021 Solutions
New Discussion

Cron Question

 
Hunki
Super Advisor

Cron Question


I have this defined in my cron entry :

10 * * * * /usr/bin/date >> /export/home/tg123/perf_stat && /usr/ucb/ps -auxww |grep java |grep tg123 |grep default |awk '{print $3" "$4}' >> /export/home/tg123/perf_stat

It runs fine at command line but its not updating the perf_stat file through the cron entry.
Any clues ?

thanks,
hunki
10 REPLIES 10
Nair1980
Frequent Advisor

Re: Cron Question

Hi

Make the full command as a script and give the script name in crontab

it may work

Uday_S_Ankolekar
Honored Contributor

Re: Cron Question

Most of the time this is due to path settings.
use set -x at top your script and then trouble shoot

-USA..
Good Luck..
Hunki
Super Advisor

Re: Cron Question

I did try putting it in a script but the date part is not getting updated in the perf file.
Yang Qin_1
Honored Contributor

Re: Cron Question

Did you check /var/adm/cron/log? maybe you can find something there.


Yang
Nair1980
Frequent Advisor

Re: Cron Question

Hi

You can put this single line as two commands in script i think..

try in this way

Hunki
Super Advisor

Re: Cron Question

I did try the two part way, but it ceases to work.

Yang Qin_1
Honored Contributor

Re: Cron Question

can you run "sh -x

Yang
Dennis Handly
Acclaimed Contributor

Re: Cron Question

Why are you using "&&" instead of just ";"?
You can also use: awk '{print $3, $4}'

> I did try the two part way, but it ceases to work.

You did it with separate lines in a script? If that fails, you need to fix that first. And as Yang says, use -x.
Yogeeraj_1
Honored Contributor

Re: Cron Question

hi hunki,

try to do a:

touch /export/home/tg123/perf_stat

(as the crontab owner)

and try again

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
jnovak
New Member

Re: Cron Question

Hi, just an idea - what about the permissions of the file perf_stat?

Does the user running the crontab the right to write into this file?