Operating System - HP-UX
1835532 Members
2964 Online
110078 Solutions
New Discussion

Re: 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
Rich Wright
Trusted Contributor

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

The user that the cron runs for should get an email showing the standard output.
You may need to change the crontab entry to this...
0 2 * * 2-5 /data2/batch/updt_iq.sh >/tmp/updt_iq.log 2>&1

Then you can look at the log file for clues about what is happening.
You may want to add "set -x" to the script to get more information.
Sanjay_6
Honored Contributor

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

Hi,

Have you checked the cron log file at /var/adm/cron/log . Check and see if the script is executed and also make sure the execute permissions are set for the script.

Hope this helps.

Regds
V. V. Ravi Kumar_1
Respected Contributor

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

hi,

give full path of ur script in the crontab.
if it is link file then use
sh before the file path

regds
Never Say No
MANOJ SRIVASTAVA
Honored Contributor

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

The script should be set to excutable otherwise they wont run.


Manoj Srivastava
Bart Beeren
Advisor

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

Did you check ownership and access_rights of the script updt_iq.sh ?(Directories underneath should be oke, since the other scripts do work fine). The script should be accessible for the user sybase.

If this is allright, go for the option of writing to a log-file mentioned by Rich Wright. Hopefully this gives you more information.

Good luck, BB

Life isn´t as simple as it seems
Steve Post
Trusted Contributor

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

I looked at your attachment. Here are 3 things to note:
1. What's with this??!?!?
0 5 18 4 4 /data2/check/check3
0 2 8 5 3 /data2/batch/create_dcfusao.sh
The format is.....
minute hr dayofmonth monthofyear dayofweek file

So it you have "0 5 18 4 4 check3" you are saying to run this ONLY on 18April at 5am ONLY if it is a THURSDAY.
0 0minutes
5 5am
18th of month
4 April
4 Thursday (0=sunday -> 6=saturday)

2. When running the cronjobs, you need to source in your environment. I.E. things like $SYBASE, and $SYBASE_ASE.
I got burned once this way.

3. I don't use "crontab -e". Instead I....
a. crontab -l > myfile
b. cp myfile crontab.previous
c. vi myfile
d. cp myfile crontab.new
e. crontab crontab.new
Why? Because you risk losing your crontab file.
I got burned once this way...too.

Hope this helps. STeve