cronjob only completes half of command

mark1491

Verified User
Joined
Jun 13, 2006
Messages
6
I have a cron job setup on one of my servers users, and have tested it in the shell and it works fine. But now when I do a cronjob

I put this command in the command part of the cron setup for example with test.com:

DATADIR="/home/test/domains/test.com/public_html/data/"; STOREFILE="/testcron/cronjobhumor/newmedianame.txt"; OLDNAME=$(head -1 $STOREFILE); NEWNAME="media"$(stat -c %Z $DATADIR$OLDNAME); mv $DATADIR$OLDNAME $DATADIR$NEWNAME; echo $NEWNAME > $STOREFILE;


But when I look at the log I only get this out of the command from above, it stops just before %


Aug 8 23:04:01 server177 crond[17486]: (test) CMD (DATADIR="/home/test/domains/test.com/public_html/data/"; STOREFILE="/testcron/cronjobhumor/newmedianame.txt"; OLDNAME=$(head -1 $STOREFILE); NEWNAME="media"$(stat -c

Do I need to have something other than the %, and if so what would that replacement be

Thanks in advance
Mark
 
Last edited:
Try escaping it with a backslash (\), shells can be pretty frustrating when using special characters. Don't know if it will help, but that is the first thing I would try.
 
I tried changing the (%) to a (\) and it didn't work, is that what you meant when you said:

Try escaping it with a backslash (\)

Thanks for helping let me know if you have any other suggestions

Thanks,
Mark
 
No, escaping means you make a '%' into '\%' so that the shell doesn't try to exapand or interpret the character as something else.
 
It worked that time with this command:

DATADIR="/home/test/domains/test.com/public_html/data/"; STOREFILE="/hotrankercron/cronjobhumor/newmedianame.txt"; OLDNAME=$(head -1 $STOREFILE); NEWNAME="media"$(stat -c \%Z $DATADIR$OLDNAME); mv $DATADIR$OLDNAME $DATADIR$NEWNAME; echo $NEWNAME > $STOREFILE;

This time the cronjob log shows the whole command there!!, but doesn't show the Z after the % ?????


DATADIR="/home/test/domains/test.com/public_html/data/"; STOREFILE="/testcron/cronjobhumor/newmedianame.txt"; OLDNAME=$(head -1 $STOREFILE); NEWNAME="media"$(stat -c % $DATADIR$OLDNAME); mv $DATADIR$OLDNAME $DATADIR$NEWNAME; echo $NEWNAME > $STOREFILE;


The Z is missing from the cron job log now, which makes the command not work still??

Thanks for helping toml, let me know if u can think of anything else!

Mark
 
Last edited:
Back
Top