Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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!

share|improve this question
    
Are you able to write it as a bash script, and then call taht from cron? –  david6 Mar 23 '13 at 2:42
add comment

1 Answer 1

You need to escape the % symbols like so:

date +\%Y_\%m

share|improve this answer
    
Switching to the \%Y format made it work! Thanks! –  user142691 Mar 23 '13 at 13:41
    
Please mark my answer as accepted if it solved your issue. –  Bert Mar 23 '13 at 16:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.