LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-21-2012, 04:50 PM   #1
kais1
Member
 
Registered: Dec 2008
Posts: 61

Rep: Reputation: 17
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
 
Old 03-21-2012, 04:53 PM   #2
kais1
Member
 
Registered: Dec 2008
Posts: 61

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by kais1 View Post
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

Last edited by kais1; 03-21-2012 at 04:58 PM.
 
Old 03-21-2012, 05:02 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Anything about cron in the system logs, or in e-Mail to the owner of that cron-tab entry?
 
1 members found this post helpful.
Old 03-21-2012, 05:06 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.
 
1 members found this post helpful.
Old 03-21-2012, 05:09 PM   #5
kais1
Member
 
Registered: Dec 2008
Posts: 61

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by Tinkster View Post
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)
 
Old 03-21-2012, 05:11 PM   #6
kais1
Member
 
Registered: Dec 2008
Posts: 61

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by suicidaleggroll View Post
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 .
 
Old 03-21-2012, 05:25 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by kais1 View Post
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?
 
1 members found this post helpful.
Old 03-22-2012, 02:35 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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
 
1 members found this post helpful.
Old 03-22-2012, 05:54 AM   #9
stuart_m
LQ Newbie
 
Registered: Oct 2010
Location: Glasgow, UK
Distribution: Fedora
Posts: 14

Rep: Reputation: 1
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
 
1 members found this post helpful.
Old 03-22-2012, 10:05 AM   #10
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
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
 
1 members found this post helpful.
Old 03-23-2012, 01:53 PM   #11
kais1
Member
 
Registered: Dec 2008
Posts: 61

Original Poster
Rep: Reputation: 17
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
 
Old 04-20-2012, 09:24 AM   #12
jcayab
LQ Newbie
 
Registered: Jun 2008
Posts: 2

Rep: Reputation: 0
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
runing sh script in cron job emymcse Linux - General 3 12-28-2009 07:38 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
runing login script with root privilleges djgerbavore Linux - Networking 8 06-16-2005 02:36 PM
runing perl unix script in windows 2000 anirudh Programming 3 04-15-2005 10:07 AM
runing shell script khucinx Programming 1 05-11-2004 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration