2

I have a line of script that works through terminal and works through cron to run one time: it downloads a file from the internet and saves it in a specific place named as the date it was found:

cd /media/path/to/folder && wget "http://www.web/address/name.gif" && mv name.gif "$(date +'%Y_%m_%d_T%H%M')"

I put this together one bit at a time, as I'm new to Ubuntu, then put it together in terminal, then ran it successfully as a one time task, entered in the "Scheduled Tasks" window. When I add it through cron with crontab -e to run on the first minute of every hour as:
1 * * * * cd ...
It ran once but didn't repeat.

When I open it in "Scheduled Tasks" it says:

Your command contains one or more of the character %, this is special for cron and cannot be used with Gnome-schedule ....

I don't understand this error, since I can use the same script with the one-time task in Scheduled Tasks without problem.
Any advice on the script error? Knowledge of why it won't repeat? Simplifications to script?
Thanks for the help!

2

1 Answer 1

1

You need to escape the % symbols like so:

date +\%Y_\%m

1
  • Switching to the \%Y format made it work! Thanks!
    – user142691
    Mar 23, 2013 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .