LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Script not runing from cron (https://www.linuxquestions.org/questions/linux-newbie-8/script-not-runing-from-cron-935757/)

kais1 03-21-2012 04:50 PM

Script not runing from cron
 
Dear all,

Linux RHEL 5 ES

We have the below entry in the cron

00 08 * * * sh /scripts/Shrink_MSM_ROM_RAT.sh > /scripts/Shrink_MSM.log

when am running it manually it works fine, but not from the crom. Folder /scripts readable and writable by all the users

Please advise

Kai

kais1 03-21-2012 04:53 PM

Quote:

Originally Posted by kais1 (Post 4632990)
Dear all,

Linux RHEL 5 ES

We have the below entry in the cron

00 08 * * * sh /scripts/Shrink_MSM_ROM_RAT.sh > /scripts/Shrink_MSM.log

when am running it manually it works fine, but not from the crom. Folder /scripts readable and writable by all the users

Please advise

Kai

In addition to the above, crond is running too .Tried the below too

* * * * * env > /tmp/env.output

not working

Tinkster 03-21-2012 05:02 PM

Anything about cron in the system logs, or in e-Mail to the owner of that cron-tab entry?

suicidaleggroll 03-21-2012 05:06 PM

Do you have a blank line between your command and the end of the crontab? I've noticed before on my systems that if there isn't a blank line after the last cron entry, it won't run.

kais1 03-21-2012 05:09 PM

Quote:

Originally Posted by Tinkster (Post 4632997)
Anything about cron in the system logs, or in e-Mail to the owner of that cron-tab entry?

Thanks Cronlog shows only the below

Mar 22 00:51:21 mederpdb1 crontab[26657]: (oracle) LIST (oracle)
Mar 22 00:51:47 mederpdb1 crontab[28982]: (oracle) BEGIN EDIT (oracle)
Mar 22 00:51:55 mederpdb1 crontab[28982]: (oracle) REPLACE (oracle)
Mar 22 00:51:55 mederpdb1 crontab[28982]: (oracle) END EDIT (oracle)
Mar 22 00:52:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)
Mar 22 00:55:43 mederpdb1 crontab[18559]: (oracle) BEGIN EDIT (oracle)
Mar 22 00:56:25 mederpdb1 crontab[18559]: (oracle) REPLACE (oracle)
Mar 22 00:56:25 mederpdb1 crontab[18559]: (oracle) END EDIT (oracle)
Mar 22 00:57:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)
Mar 22 00:57:58 mederpdb1 crontab[30992]: (oracle) LIST (oracle)
Mar 22 00:59:13 mederpdb1 crontab[5615]: (oracle) BEGIN EDIT (oracle)
Mar 22 00:59:36 mederpdb1 crontab[5615]: (oracle) END EDIT (oracle)
Mar 22 01:00:01 mederpdb1 crond[10129]: (root) CMD (/usr/lib/sa/sa1 1 1)
Mar 22 01:01:01 mederpdb1 crond[15635]: (root) CMD (run-parts /etc/cron.hourly)
Mar 22 01:01:26 mederpdb1 crontab[18035]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:02:23 mederpdb1 crontab[18035]: (oracle) REPLACE (oracle)
Mar 22 01:02:23 mederpdb1 crontab[18035]: (oracle) END EDIT (oracle)
Mar 22 01:02:41 mederpdb1 crontab[24905]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:02:48 mederpdb1 crontab[24905]: (oracle) REPLACE (oracle)
Mar 22 01:02:48 mederpdb1 crontab[24905]: (oracle) END EDIT (oracle)
Mar 22 01:03:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)
Mar 22 01:03:41 mederpdb1 crontab[30507]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:03:53 mederpdb1 crontab[30507]: (oracle) END EDIT (oracle)
Mar 22 01:03:58 mederpdb1 crontab[32120]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:04:10 mederpdb1 crontab[32120]: (oracle) REPLACE (oracle)
Mar 22 01:04:10 mederpdb1 crontab[32120]: (oracle) END EDIT (oracle)
Mar 22 01:04:13 mederpdb1 crontab[1172]: (oracle) LIST (oracle)
Mar 22 01:05:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)

kais1 03-21-2012 05:11 PM

Quote:

Originally Posted by suicidaleggroll (Post 4633003)
Do you have a blank line between your command and the end of the crontab? I've noticed before on my systems that if there isn't a blank line after the last cron entry, it won't run.

NO There is no blank line .

Tinkster 03-21-2012 05:25 PM

Quote:

Originally Posted by kais1 (Post 4633005)
Thanks Cronlog shows only the below

Mar 22 00:51:21 mederpdb1 crontab[26657]: (oracle) LIST (oracle)
Mar 22 00:51:47 mederpdb1 crontab[28982]: (oracle) BEGIN EDIT (oracle)
Mar 22 00:51:55 mederpdb1 crontab[28982]: (oracle) REPLACE (oracle)
Mar 22 00:51:55 mederpdb1 crontab[28982]: (oracle) END EDIT (oracle)
Mar 22 00:52:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)
Mar 22 00:55:43 mederpdb1 crontab[18559]: (oracle) BEGIN EDIT (oracle)
Mar 22 00:56:25 mederpdb1 crontab[18559]: (oracle) REPLACE (oracle)
Mar 22 00:56:25 mederpdb1 crontab[18559]: (oracle) END EDIT (oracle)
Mar 22 00:57:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)
Mar 22 00:57:58 mederpdb1 crontab[30992]: (oracle) LIST (oracle)
Mar 22 00:59:13 mederpdb1 crontab[5615]: (oracle) BEGIN EDIT (oracle)
Mar 22 00:59:36 mederpdb1 crontab[5615]: (oracle) END EDIT (oracle)
Mar 22 01:00:01 mederpdb1 crond[10129]: (root) CMD (/usr/lib/sa/sa1 1 1)
Mar 22 01:01:01 mederpdb1 crond[15635]: (root) CMD (run-parts /etc/cron.hourly)
Mar 22 01:01:26 mederpdb1 crontab[18035]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:02:23 mederpdb1 crontab[18035]: (oracle) REPLACE (oracle)
Mar 22 01:02:23 mederpdb1 crontab[18035]: (oracle) END EDIT (oracle)
Mar 22 01:02:41 mederpdb1 crontab[24905]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:02:48 mederpdb1 crontab[24905]: (oracle) REPLACE (oracle)
Mar 22 01:02:48 mederpdb1 crontab[24905]: (oracle) END EDIT (oracle)
Mar 22 01:03:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)
Mar 22 01:03:41 mederpdb1 crontab[30507]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:03:53 mederpdb1 crontab[30507]: (oracle) END EDIT (oracle)
Mar 22 01:03:58 mederpdb1 crontab[32120]: (oracle) BEGIN EDIT (oracle)
Mar 22 01:04:10 mederpdb1 crontab[32120]: (oracle) REPLACE (oracle)
Mar 22 01:04:10 mederpdb1 crontab[32120]: (oracle) END EDIT (oracle)
Mar 22 01:04:13 mederpdb1 crontab[1172]: (oracle) LIST (oracle)
Mar 22 01:05:01 mederpdb1 crond[4629]: (oracle) RELOAD (cron/oracle)

And mail?

pan64 03-22-2012 02:35 AM

crontab entries run in a special environment, so maybe sh and env cannot be evaluated. Check PATH variable, or try to use full path:

Code:

00 08 * * * /usr/bin/sh /scripts/Shrink_MSM_ROM_RAT.sh > /scripts/Shrink_MSM.log

stuart_m 03-22-2012 05:54 AM

Code:

/scripts/Shrink_MSM_ROM_RAT.sh
Is that the full path to the script you are trying to run? Are there any relative paths or variables in the script itself which would make sense when you manually run the script but not so much when the script is run by cron? I have found in the past when a job like this fails it is because the script runs OK under my login but it contains shortcuts or variables which are specific to my login and are not available to cron

Sydney 03-22-2012 10:05 AM

I have had to change working directory on stuff like this before. This may help it may be redundant. I would also capture error stream with 2>&1.

00 08 * * * cd /scripts && /usr/bin/sh Shrink_MSM_ROM_RAT.sh > Shrink_MSM.log 2>&1

kais1 03-23-2012 01:53 PM

Thanks , Issue resovled . if am scheduling the cron after 5 minutes from the system time, it works fine.. not immediately. Am sure it doesn't make sense. but it works like that.

Thanks to all

Kai

jcayab 04-20-2012 09:24 AM

Hi Kai,

I'm having the same issue. Would appreciate if you post a sample entry of before and after you got it working.

Thanks!


All times are GMT -5. The time now is 02:05 AM.