Computing.Net > Forums > Unix > Want to run a shell script through cron job

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Want to run a shell script through cron job

Reply to Message Icon

Name: gurnanit
Date: August 28, 2009 at 03:13:38 Pacific
OS: Unix
Subcategory: General
Comment:

Hi,

The problem that I am facing is as below:
There is a shell script which take 2 dates as input (today's date and yesterday's date) and when I am running the below command on Unix prompt, it is running fine.

The command is

$SIEBEL_ROOT/eim/EIM_Asset_Inactivate/call_Update_AssetStatus.sh "`TZ="GMT+24" date +'%d/%m/%Y'`" "`date '+%d/%m/%Y'`"

But when I am giving the same command in cron job, it is running but it is not taking the input dates.

Cron job entry is

0 5 * * * $SIEBEL_ROOT/eim/EIM_Asset_Inactivate/call_Update_AssetStatus.sh "`TZ="GMT+24" date +'%d/%m/%Y'`" "`date '+%d/%m/%Y'`"

Could you please help me in resolving this issue.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 28, 2009 at 10:38:14 Pacific
Reply:

Typically, when a script runs from the command line, it's because the cron environment is different from the environment where the script was developed.

First, are you sure that the cron environment knows about this environmental var: $SIEBEL_ROOT

Second, I would make sure the call_Update_AssetStatus.sh script has a shell envocation on line 1: #!/bin/ksh or #!/bin/sh
Every non-linix cron I have worked with assumes #!/bin/sh.

I would also make sure that call_Update_AssetStatus.sh sets its own environmenatl variables such as PATH.

Does the script assume you have to be in a certain directory that the cron enviironment will not know about? That could trip you up.


0

Response Number 2
Name: gurnanit
Date: August 28, 2009 at 23:08:26 Pacific
Reply:

Previously it was not working, later I have changed the environment variable with actual path.
Now the current cron tab entry is

0 5 * * * /siebel/vlmPRD/siebsrvr/eim/EIM_Asset_Inactivate/call_Update_AssetStatus.sh "`TZ="GMT+24" date +'%d/%m/%Y'`" "`date '+%d/%m/%Y'`"

Now file is executing but the problem is that the 2 input arguments that I am passing is not getting converted to dates i.e. "`TZ="GMT+24" date +'%d/%m/%Y'`" "`date '+%d/%m/%Y'`"
these 2 input arguments are yesterday's date and current date.
Please let me know how it will work.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Want to run a shell script through cron job

how to Call a shell script www.computing.net/answers/unix/how-to-call-a-shell-script/3640.html

Running a shell script as root www.computing.net/answers/unix/running-a-shell-script-as-root/8137.html

Running a shell script from cron www.computing.net/answers/unix/running-a-shell-script-from-cron/4091.html