Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call script from Cron

Status
Not open for further replies.

njoydb

Programmer
Mar 21, 2006
2
US
Hi,

I need to call a script from cron which needs an argument which is also a script. The argument script needs another text file as an argument. How could I put in cron. I tried like this, but it doesn't work.

00 08 * * * Script1.sh ( Script2.sh One.lst ) 2>&1

Any help??

Thanks,
njoydb
 
Hi,

imho this is not a cron question.
First of all run your Script1.sh from command prompt, with an argument script, and with an argument textfile for the argument script. Once you have successfully done this, you may use the same syntax for cron.

What have you got so far?
 
Hi

No script has another script as argument. Arguments are strings. So that argument is eighter to second script's name, or the output returned by the second script.

Try again explaining your problem.

And that command should work the same way as from command line. ( With the exception that the environment could differ when runned from a daemon, like [tt]cron[/tt]. )

Feherke.
 
Easy: just use

00 08 * * * /path/to/Script1.sh /another_path/to/Script2.sh /one/more/path/to/One.lst 2>&1 >/tmp/Script1.out

From cron, it is better to use absolute paths, because cron doesn't have a full process environment like you have on-line.

Then in Script1.sh, make sure that the context which contains the line which runs the other script is sth. like:

# run the script named in first parameter with it's own parameter
# which this calling script has received as 2nd parameter
secondscript=$1
paramfor2nd=$2
$secondscript $paramfor2nd




HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top