1847860 Members
2553 Online
104021 Solutions
New Discussion

Crontab probelm

 
Sameer S
Advisor

Crontab probelm

Hi frens,

I am facing some problem in executing crontab.
When I put a shell script i have written in crontab or even try executing it using a"at", it is not executing. But if I try executing it directly, it works.
Does somebody have a solution ???
Let us grow our knowledge by sharing ...
9 REPLIES 9
Steve Steel
Honored Contributor

Re: Crontab probelm

Hi

You can execute crontab if your name appears in the file
/var/adm/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file
/var/adm/cron/cron.deny. If only cron.deny exists and is empty, all

Hewlett-Packard Company - 2 - HP-UX Release 10.20: July 1996

crontab(1) crontab(1)

users can use crontab. If neither file exists, only the root user can
use crontab.


Steve Steel

To meet your daily target. Aim Fir call what you hit the target
If you want truly to understand something, try to change it. (Kurt Lewin)
Rajeev  Shukla
Honored Contributor

Re: Crontab probelm

You can look for the error in /var/adm/cron/log file
and i guess you are giving the complete path of the file you are executing using cron.

Rajeev
Christian Gebhardt
Honored Contributor

Re: Crontab probelm

Hi

if you execute a shell-script with cron/at the /etc/profile and $HOME/.profile are not sourced, so cronjobs have an other environment.

To be sure to have the correct environment you have to do something like that:
0 0 * * * (. /etc/profile; . ./.profile;
If you are using c-shell you have to source /etc/csh.login, $HOME/.cshrc and maybe $HOME/.login

Chris
T G Manikandan
Honored Contributor

Re: Crontab probelm

I have had problems like that
Restarting the cron daemon does solve the problem


Thanks
Robin Wakefield
Honored Contributor

Re: Crontab probelm

Hi,

These are usually caused by environment issues. Check out:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x04945220af9bd5118ff10090279cd0f9,00.html

rgds, Robin
monasingh_1
Trusted Contributor

Re: Crontab probelm

Also check the special char being used. Like date +%a will work fine when you execute in shell but will not work in crontab. you will need to give escape char before %. (date +\%a)

So if you are passing any option to your script in cron then escape it...

hope this helps...
Stanimir
Trusted Contributor

Re: Crontab probelm

Hi!
In addition - do you ensure the correct output
for your script in crontab:
00 10 * * *
Regards.
Jim Walls
Trusted Contributor

Re: Crontab probelm

If you are using HP-UX 11.0 you may need to apply a cron patch. See this posting...

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x70d0a848deccd61190050090279cd0f9,00.html

Regards
Jim
Yogeeraj_1
Honored Contributor

Re: Crontab probelm

hi,

try to run it by doing a su!


e.g. Root's cron and "yd" is the user using which the shell script works (directly)!


5 13 * * 1 echo "/home/yd/myscript.sh"|su - yd 1>/home/yd/output-myscript.crn 2>/home/yd/error-
myscript.crn
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************

The .crn files will help you troubleshoot any further errors.

Hope this helps!

Best Regards
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)