The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
inconsistent ls command display at the command prompt & running as a cron job rajranibl Linux 5 07-30-2007 05:26 AM
at command does not work otilesoj UNIX for Dummies Questions & Answers 0 03-24-2007 03:00 AM
script didn;t work in cron !!! @_@ stancwong Shell Programming and Scripting 2 10-04-2005 06:25 AM
ncopy doesn't work from cron Selma UNIX for Dummies Questions & Answers 2 01-20-2005 05:28 AM
Simple cron job won't work coregan UNIX for Dummies Questions & Answers 4 01-20-2004 01:22 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-20-2006
Registered User
 

Join Date: Jan 2006
Posts: 5
Stumble this Post!
Command doesn't work under cron ?

I have defined in cron
crontab -l >/FIXENGINE/data/crontab.$(whoami).$(date +%a)

The resulting file is named
crontab.fixadmin.

When I run the above from a command line, the file is named:
crontab.fixadmin.Tue (or whatever day I happen to be running)

The question is - why do I get different results.

Any ideas??

John
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-20-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
Stumble this Post!
What shell is cron running under? $() is Korn specific so back ticks may solve your issue; eg. `whoami`.
Reply With Quote
  #3 (permalink)  
Old 01-20-2006
Registered User
 

Join Date: Jan 2006
Posts: 5
Stumble this Post!
I assume I'm running under Korn - note that the $(whoami) works
echo $SHELL generated an email to the acct with out a result

I did try `date +%a` (backquotes) - still didn't work

john
Reply With Quote
  #4 (permalink)  
Old 01-20-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,425
Stumble this Post!
Please try to provide a clue or two when you ask questions. It would help a lot to know exactly which OS you use. But from Sun's crontab man page:
Quote:
Only the first line (up to a ` % ' or end of line) of the command field is executed by the shell.
I'm guessing that is your issue.
Reply With Quote
  #5 (permalink)  
Old 01-20-2006
Registered User
 

Join Date: Jan 2006
Posts: 5
Stumble this Post!
Thank you - you nailed it

I escaped the % sign and it now works fine

crontab -l >/FIXENGINE/data/crontab.$(whoami).$(date +\%a)

Thank you again

John

BTW - am running HPUX 11
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0