The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Operating Systems
> UNIX Help
|
passing argument in cron job
Discuss passing argument in cron job in the UNIX Help forum on Dev Shed. passing argument in cron job UNIX Help forum discussing the Unix Operating System and all variants including Irix, Solarix, and AIX. Unix was designed as a true multi-user operating system.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 20th, 2004, 08:37 AM
|
|
Registered User
|
|
Join Date: Aug 2002
Location: Leicester
Posts: 7
Time spent in forums: 11 m 57 sec
Reputation Power: 0
|
|
|
passing argument in cron job
I am new to cron, and need some advice. I currently have a shell script which runs like the example shown below. There are 4 of these duplicates I want to run. But I want to pass an arguement so that it changes to a different user-id within the script
0,5,10,15,20,25,30,35,40,45,50,55 ***** /../../../test.sh 2 [want to add an argument here for example $userid=xyz] >&1.
Now in this shell script there is a variable which needs to be changed when the cron job runs.
Example in shells script:
$user-id = (this needs to be defined from the cron job)
Can anyone help with this.
|

October 22nd, 2004, 03:11 AM
|
|
Contributing User
|
|
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,200
  
Time spent in forums: 1 Week 1 Day 11 h 47 m 52 sec
Reputation Power: 12
|
|
|
yes you need advice.
this is wrong:
0,5,10,15,20,25,30,35,40,45,50,55 *****
see man pages crontab
this is not really intelligent
0,5,10,15,20,25,30,35,40,45,50,55
and this is inpossible
/../../../test.sh
|

October 22nd, 2004, 04:49 PM
|
|
Contributing User
|
|
Join Date: Dec 2003
Location: USA
Posts: 334

Time spent in forums: 1 Day 12 h 51 m 17 sec
Reputation Power: 10
|
|
|
First never use relative paths in cron jobs i.e. /../../../test.sh
Always provide the full path i.e. /home/fpm/test.sh
Second, you can pass arguments to test.sh but it is up to
test.sh to interpret them as command line arguments.
Form a typical crontab(5) manpage ....
The ``sixth'' field (the rest of the line) specifies the
command to be run. The entire command portion of the
line, up to a newline or % character, will be executed by
/bin/sh or by the shell specified in the SHELL variable of
the cronfile. Percent-signs (%) in the command, unless
escaped with backslash (\), will be changed into newline
characters, and all data after the first % will be sent to
the command as standard input.
|

October 24th, 2004, 04:56 AM
|
|
Contributing User
|
|
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,200
  
Time spent in forums: 1 Week 1 Day 11 h 47 m 52 sec
Reputation Power: 12
|
|
|
fpmurphy:
First never use relative paths in cron jobs i.e. /../../../test.sh
is that a relative path ?
IMO it's very absolute
pointing to an absolutely impossible path
|

September 24th, 2012, 01:56 AM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 1
Time spent in forums: 3 m 59 sec
Reputation Power: 0
|
|
|
thank you!
fpmurphy, your post gave me the answer to my issue immediately. it's remarkable because you pasted in the part of the manpage that would help me (regarding %). if you hadn't done that, i'd still be looking.
i definitely need to start reading manpages first... they always surprise me with how informative they are.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|