Forum Moderators: bakedjake

Message Too Old, No Replies

Dynamic data in CRON command

         

George_hu

10:15 pm on Apr 10, 2005 (gmt 0)

10+ Year Member



My final goal is to make a CRON job for fetching backup from other CPanel host.

This is not so easy since the backup name changing daily as the calendar.
CPanel backup creating this way: backup-somehost.com-m-d-Y.tar.gz

The date format is not contains an leading zeros, so i need to modify the original
date format.

I can manage this in shell>
echo `date +%m-%d-%Y ¦ sed -e 's/^0//g' ¦ sed -e 's/0//'`
so the result is as the desired>
4-10-2005

I tried to inplement this as dynamic parameter in cron job>
wget echo [aaa:bbb@ccc.com:2083...] +%m-%d-%Y ¦ sed -e 's/^0//g' ¦ sed -e 's/0//'`.tar.gz

However this was a failure.
Anyone kind enough to enlight me about this situation?

This is the result>
/bin/sh: -c: line 1: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 2: syntax error: unexpected end of file

However manipulating the date from shell OK.
I suppose this must work someway... however my *nix/cron knowledge is not enough for this.

Any suggestion or idea?

Romeo

10:57 pm on Apr 10, 2005 (gmt 0)

10+ Year Member



Hi George,

it looks like the "%" within the date command are interpreted by the cron as start of command input and subdividing the input into separate lines, before the whole thing gets interpreted by the shell.

I don't know the exact syntax for that complex crontab entry, but you may circumvent this problem by writing that
wget echo https.....
statement into a shell script and then just running that shell script in cron
/full/path/wgetscript.sh

Be sure to set the ownership and permissions of that wgetscript.sh to r-x------ for the crontab user only, so that other users can't put in other commands to be executed.

Regards,
R.