[NTLUG:Discuss] OT: crontab arguments question

Fred James fredjame at fredjame.cnc.net
Sat Feb 23 21:01:18 CST 2008


Leroy Tennison wrote:

>Fred James wrote:
>  
>
>>All
>>OT: crontab arguments question
>>I need to pass an argument to my program from the crontab entry
>>Problem: the first argument is taken by an environmental script
>>Question: how do I provide for this?
>>
>>Example:
>>55 13 * * * su - oracle -c /apps/oracle/ppdb_scripts/SidTest/willi.sh ppdb
>>    the su - oracle -c is required to set certain environmental variable 
>>or nothing works
>>    the ppdb is the SID the the su - oracle eats up on the way through, 
>>and I need to send another ppdb to my program
>>
>>something like ...
>>55 13 * * * su - oracle -c /apps/oracle/ppdb_scripts/SidTest/willi.sh 
>>ppdb ppdb
>>... except that doesn't work ...
>>
>>Thank you in advance for any help you may be able to offer
>>Regards
>>Fred James
>>    
>>
>I have no idea if this would work or not but can you embed some (or all) 
>of the execution/parameter stuff in a script file and then refer to the 
>script in the crontab?  I'm hoping that a script will give you enough 
>isolation that the right program can get it's necessary parameters.
>  
>
Leroy Tennison
There are a growing number scripts that are meant to be generic to 
several different servers, with the variable being the SID (site ID), 
and there may be multiple SIDs on any one server.  The SID then is part 
of the directory paths, as well as the value passed to such things as 
oraenv.  Each generic scripts then will usually have a single hard coded 
value to be modified when it is ported from one SID to another - the 
directory paths in all the SIDs are kept identical except  for the SID 
value.

These scripts could be even more generic, and more portable, if the SID 
didn't have to be hard coded - thus the desirability of passing the SID 
to the script in the command of the active crontab entry.  What I 
finally found is that if one uses a crontab entry like this ...
    42 20 * * * su - oracle -c 
/apps/oracle/ppdb_scripts/SidTest/willi.sh < 
/apps/oracle/ppdb_scripts/SidTest/Name
... and a line in the script (near the top) like this ...
    read sid
... and the file "/apps/oracle/ppdb_scripts/SidTest/Name" contains a 
single line with only the SID, then problem solved!  At least all this 
works in an SGI IRIX 6.4 Bourne Shell script - YMMV.
Regards
Fred James


I have not been able to get a work around - the


More information about the Discuss mailing list