1753518 Members
5117 Online
108795 Solutions
New Discussion юеВ

Re: query on crontab

 
SOLVED
Go to solution
Md. Minhaz Khan
Super Advisor

query on crontab

Dear All,

I have written a script(pkg_check.sh) to monitor MC/ServiceGuard cluster status(down,halting,down..) which is attached with this thread. The Problem
is that when i run this script using "sh pkg_check.sh" command it works fine
but when i want to run this script using cron job only "cmviewcl -v

>/pkg_test/cluster_status.txt" command only work.Other part of this script
is not working. I have given following entry in the cron schedule:

0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * su - root -c "/pkg_test/pkg_check.sh" 1>/dev/null 2>/dev/null

I have checked "/var/adm/cron/cron.allow".Here "root" user exist.I have already set
permission 777 of pkg_check.sh script. But no works.

Can any one help me that where is my problem??

Thanks
Minhaz
4 REPLIES 4
Md. Minhaz Khan
Super Advisor

Re: query on crontab

" cmviewcl -v" output is attach.
Johnson Punniyalingam
Honored Contributor

Re: query on crontab

Hi ,

Can you try putting the crontab entry under root like below

Login:- root

# crontab -e

0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /pkg_test/pkg_check.sh

:wq!

I suspect you are ready under root, no need to su - root -c .. while crontab.?

also best place to check tunder cron.logs

cat /var/adm/cron/cron.log ?

HTH,

Rgds,
Johnson
Problems are common to all, but attitude makes the difference
Hakki Aydin Ucar
Honored Contributor
Solution

Re: query on crontab

two things must be considered first when running a code via cronjob :

Everything must use full path
and user privilege.

-I recommend use full path instead of relative path; for example use /usr/bin/date not date ..

-your script must have execute privilege.

and besides ,since I am not sure your syntax is correct; if you use user root you can enter like this ;

0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /pkg_test/pkg_check.sh > /dev/null 2>&1




Md. Minhaz Khan
Super Advisor

Re: query on crontab

Thanks everybody. Problem was solved

Minhaz