Operating System - HP-UX
1753971 Members
8685 Online
108811 Solutions
New Discussion юеВ

Crontab doesn't execute a new script...

 
Halan Leno Borges Dias
Occasional Contributor

Crontab doesn't execute a new script...

Dear all,

I've been a problem with contrab.I've a crontab entry that had 4 scripts runnning fine.I needed add a new script but it's doesn't work anyway.The changes was made from crontab -e.
I've tested the script manualy and it works fine.
Some help would be very appreciated.
Halan Leno
15 REPLIES 15
Luc Bussieres_1
Trusted Contributor

Re: Crontab doesn't execute a new script...

We will need more information to be able to help you,
what is your crontab entry?
do you know if cron start the script and then it fail or the script is never run?
If the script is run it's possible that you could execute your script manually and when the script is executed in cron it will fail. The reason is that cron will not read your .profile file and all the environment variables (like PATH) won't be define. so you should make sure that you always use full path for your commands inside your script.

Luc
Pete Devlin
Valued Contributor

Re: Crontab doesn't execute a new script...

Is the user this script runs as in the cron.allow file ?
Peter Kloetgen
Esteemed Contributor

Re: Crontab doesn't execute a new script...

Hi Halan,

i think you are perhaps missing the path to your script so the shell can't find it. Try the following:

0 * * * * /path/to/your/script

or you could edit your /etc/PATH file:

vi /etc/PATH --> A (append at end of line)

:/path/to/your/script/directory

ESC

:wq!

after this you have to relogin to get it to work.

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Juan Gonz├бlez
Trusted Contributor

Re: Crontab doesn't execute a new script...

Hi Halan,
you can look at /var/adm/cron/log to see if the script is executed. But i agree with Luc that it must be a problem with the env variables, like PATH, SHELL...You migth set them at the begining of the script.

Best regards
Juan
steven Burgess_2
Honored Contributor

Re: Crontab doesn't execute a new script...

Halan

ensure at the end of your new entry you have 2>&1 to redirect stderr and stdout

Also, you generally shouldn't need to stop and start cron because of the way you have added your entry via crontab -e. Give it a go and reset cron

/sbin/init.d/cron stop
/sbin/init.d/cron start

Check the permissions on your new script with regard to the cron user if not root

Please post the crontab file

HTH

Steve

take your time and think things through
john korterman
Honored Contributor

Re: Crontab doesn't execute a new script...

Hi,
is you cron daemon running? If yes, there shold be messages about the execution of the scripts in /var/adm/cron/log
Any clues there?

regards,

John K.

it would be nice if you always got a second chance
Peter Kloetgen
Esteemed Contributor

Re: Crontab doesn't execute a new script...

Hi again, Halan,

the standard output and standard error for cron is the mail account of the user which run the cron job. Perhaps your script *has* been executed but you do not see the results/output?
Look into your mail account to verify this.

you have to redirect the output of your script if you want to see it:

0 * * * * /path/to/script 1>/dev/pts/0 2>&1

--> would redirect your scripts output to a terminal, also error message is redirected there.

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Halan Leno Borges Dias
Occasional Contributor

Re: Crontab doesn't execute a new script...

People please, see the attached file called sybase.Sybase is the user who execute the crontab.I??ve to tell you that the others scripts in this contrab run fine without any problem.I've checked the evn and path everything seem be work perfectly also I checked the /var/adm/cron/log and saw some entry about the script: /data2/batch/updt_iq.sh but it doesn't run...

Regards !

Halan Leno
Brazil - Sao Paulo
Halan Leno
Peter Kloetgen
Esteemed Contributor

Re: Crontab doesn't execute a new script...

Hi Halan,

the entry in your cronfile seems to be ok. Did you have a look to the mail account of the user sybase? Can you please post your script here to find out if the error is in script code? Perhaps the script needs some parameters which are used inside it?

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping