Command doesn't work under cron ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command doesn't work under cron ?
# 1  
Old 01-20-2006
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
# 2  
Old 01-20-2006
What shell is cron running under? $() is Korn specific so back ticks may solve your issue; eg. `whoami`.
# 3  
Old 01-20-2006
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
# 4  
Old 01-20-2006
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.
# 5  
Old 01-20-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

7z command for files larger than 4GB ( unzip doesn't work)

My unzip command doesn't work for files that are greater than 4GB. Consider my file name is unzip -p -a filename.zip, the command doesn't work since the size of the file is larger. I need to know the corresponding 7z command for the same. This is my Unix shell script program: if then ... (14 Replies)
Discussion started by: chandraprakash
14 Replies

2. Shell Programming and Scripting

Ssh remote command doesn't work from script file

I have 10 application servers in a distributed architecture generating their own application logs. Each server has application utility to continuously tail the log. for example following command follows tails and follows new logfiles as they are generated server1$ logutility logtype When I run... (8 Replies)
Discussion started by: indianya
8 Replies

3. Solaris

Mount command doesn't work on Solaris System

Hi All, I am using a solaris Sun-Fire-V440 server. The OS is solaris. My problem is whenever I run the command mount | grep "^/ " | sed -e 's,^.*dsk/\(*\).*$,\1,' it should return a disk value as "d30" as it does on each of my other servers.But on this server I am not getting any o/p from... (3 Replies)
Discussion started by: vivek.goel.piet
3 Replies

4. Shell Programming and Scripting

sed command works on Fedora/Ubuntu, but doesn't work in Mac

Hi, I have a question. I define a function using sed command: replace() { searchterm=$1 replaceterm=$2 sed -e "s/$searchterm/$replaceterm/ig" $3 > $WORK'tempfile.tmp' mv $WORK'tempfile.tmp' $3 } Then I call replace 'test = 0' 'test = 1' $myfile This code... (1 Reply)
Discussion started by: Dark2Bright
1 Replies

5. Shell Programming and Scripting

sed command works on Fedora/Ubuntu, but doesn't work in Mac

Hi, I have a question. I define a function using sed command: replace() { searchterm=$1 replaceterm=$2 sed -e "s/$searchterm/$replaceterm/ig" $3 > $WORK'tempfile.tmp' mv $WORK'tempfile.tmp' $3 } Then I call replace 'test = 0' 'test = 1' $myfileThis code works well in... (1 Reply)
Discussion started by: Dark2Bright
1 Replies

6. UNIX for Dummies Questions & Answers

find command in shell script doesn't work

Hello all, Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped :) Here's the code of my... (2 Replies)
Discussion started by: StijnV
2 Replies

7. Shell Programming and Scripting

cd command doesn't work through variables

Hi.... cd command is not working when dual string drive/volume name is passed to cd through variables....... For Ex.... y=/Volumes/Backup\ vipin/ cd $y the above command gives error....... anyone with a genuine solution ? (16 Replies)
Discussion started by: vipinchauhan222
16 Replies

8. Shell Programming and Scripting

Script doesn't work as expected when run on cron

The script checks for free space stats on Oracle. If there are any tablespaces with more than 85% usage it prints the details of the tablespace. If all the tablespaces have more than 15% free space, then "All tablespaces have more than 15 pct free space" must be printed on the screen. When I run... (2 Replies)
Discussion started by: RoshniMehta
2 Replies

9. UNIX for Dummies Questions & Answers

ncopy doesn't work from cron

Hello, I have put the following command in a shell script: ncopy /home/Selma/my_file server2\!INPUT/my_file userpassword (server2 is the remote machine) The script works fine when it is invoked manually, however when it is scheduled to be run from crontab ncopy doesn't work (all of the... (2 Replies)
Discussion started by: Selma
2 Replies

10. Shell Programming and Scripting

command line work script doesn't

Hello, I'm stuck and confused as to why when I execute things form the command line it works but when in a script it doesn't. My script: ### creating a lock on the console touch /var/run/console.lock chmod 600 /var/run/console.lock echo "$User" >>... (2 Replies)
Discussion started by: larry
2 Replies
Login or Register to Ask a Question