Unix/Linux Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

crontab not working

Solaris


Tags
crontab

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-20-2011   -   Original Discussion by isaacniu
isaacniu's Unix or Linux Image
isaacniu isaacniu is offline
Registered User
 
Join Date: Dec 2011
Last Activity: 21 December 2012, 2:46 AM EST
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Unix or Linux Question crontab not working

Shell = ksh

Hi all,

I scheduled an automated job on my application server like below,

30 13 * * 1-5 $HOME/my_script.sh

However the script was not executed as expected. Any reason that may cause this to happen?
Sponsored Links
    #2  
Old Unix and Linux 12-20-2011   -   Original Discussion by isaacniu
pmm's Unix or Linux Image
pmm pmm is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 29 April 2018, 9:58 PM EDT
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
change to:
30 13 * * 1-5 $HOME/my_script.sh > $HOME/my_script.log 2>&2
to get stdout and stderr output.
I have seen this before - where the environment is NOT set up correctly when running from crontab
You may need to set up expected environmental variables manually.
Sponsored Links
    #3  
Old Unix and Linux 12-21-2011   -   Original Discussion by isaacniu
amitranjansahu's Unix or Linux Image
amitranjansahu amitranjansahu is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 9 May 2017, 8:36 AM EDT
Location: Bangalore,INDIA
Posts: 507
Thanks: 4
Thanked 27 Times in 27 Posts
you need to take the logs for the cron job . Most likely its a env variable issue as cron does not set your env variables by default. You need to check the cronrun log file to find the details . Defile the exact path instead of defining a variable.($HOME/my_script.sh )


PHP Code:
30 13 * * 1-5 $HOME/my_script.sh >> /var/log/cronrun 2>&1
change to
30 13 
* * 1-/USR/dir/my_script.sh >> /var/log/cronrun 2>&
The Following User Says Thank You to amitranjansahu For This Useful Post:
isaacniu (12-21-2011)
    #4  
Old Unix and Linux 12-21-2011   -   Original Discussion by isaacniu
itkamaraj's Unix or Linux Image
itkamaraj itkamaraj is offline Forum Advisor  
Registered User
 
Join Date: Apr 2010
Last Activity: 29 April 2018, 8:17 AM EDT
Posts: 3,148
Thanks: 45
Thanked 698 Times in 674 Posts
If you are using any files or directories inside your my_script.sh, then use the absolute path ( from the root / )
Sponsored Links
    #5  
Old Unix and Linux 12-21-2011   -   Original Discussion by isaacniu
isaacniu's Unix or Linux Image
isaacniu isaacniu is offline
Registered User
 
Join Date: Dec 2011
Last Activity: 21 December 2012, 2:46 AM EST
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by pmm View Post
change to:
30 13 * * 1-5 $HOME/my_script.sh > $HOME/my_script.log 2>&2
to get stdout and stderr output.
I have seen this before - where the environment is NOT set up correctly when running from crontab
You may need to set up expected environmental variables manually.
Yeah, like you said, I defined some variables in that particular script. Probably these variables are not recognised by the Unix environment? So what should I do in such cases?

Manually define them and then export?
Sponsored Links
    #6  
Old Unix and Linux 01-09-2012   -   Original Discussion by isaacniu
vivek.goel.piet's Unix or Linux Image
vivek.goel.piet vivek.goel.piet is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 19 December 2013, 1:41 AM EST
Posts: 72
Thanks: 12
Thanked 3 Times in 3 Posts
This type of problems occur mainly because of improper environment. Please provide the script lines so that we can dig further and suggest which environment variables to use..
Thanks
Sponsored Links
    #7  
Old Unix and Linux 01-09-2012   -   Original Discussion by isaacniu
Ex-SUN's Unix or Linux Image
Ex-SUN Ex-SUN is offline
Registered User
 
Join Date: Nov 2011
Last Activity: 8 November 2012, 2:56 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by isaacniu View Post
Yeah, like you said, I defined some variables in that particular script. Probably these variables are not recognised by the Unix environment? So what should I do in such cases?

Manually define them and then export?
On a slightly different path, how did you create the cronjob?
Did you set the shell environment variable to vi? Did you run crontab -e to modify the cronjob file?
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
crontab is not working. getrue Solaris 6 07-27-2011 12:34 AM
crontab not working lg123 UNIX for Dummies Questions & Answers 2 04-24-2011 03:47 PM
crontab not working rajesh_hv UNIX for Advanced & Expert Users 4 10-28-2008 07:45 AM
crontab NOT working baanprog UNIX for Advanced & Expert Users 2 09-26-2006 12:11 PM
crontab not working right kymberm UNIX for Dummies Questions & Answers 3 07-09-2003 04:21 PM



All times are GMT -4. The time now is 12:23 PM.