UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 20th, 2004, 08:37 AM
corv corv is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Leicester
Posts: 7 corv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old October 22nd, 2004, 03:11 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,200 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
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

Reply With Quote
  #3  
Old October 22nd, 2004, 04:49 PM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 334 fpmurphy User rank is Private First Class (20 - 50 Reputation Level)fpmurphy User rank is Private First Class (20 - 50 Reputation Level) 
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.

Reply With Quote
  #4  
Old October 24th, 2004, 04:56 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,200 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
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

Reply With Quote
  #5  
Old September 24th, 2012, 01:56 AM
tje210 tje210 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 1 tje210 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > passing argument in cron job

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap