views:

486

answers:

1

I have a bit of a pickle here and wonder if anyone can give me some pointers:

I have a cron job which executes for a particular user daily and is supposed to sweep files in a particular directory. Technically, it is two jobs. I've turned on cron.log to verify they're actually executing, and they are:

May 24 11:03:01 AppNameGoesHere /USR/SBIN/CRON[11257]: (mongrel_AppNameGoesHere) 
  CMD (rm -rf /var/www/apps/AppNameGoesHere/current/public/
  {popular,index,purchasing,purchasing-alternate,support,about-us,guarantee,screenshots}.htm{,l})
May 24 11:04:01 AppNameGoesHere /USR/SBIN/CRON[11260]: (mongrel_AppNameGoesHere)
  CMD (rm -rf /var/www/apps/AppNameGoesHere/current/public/
  {stats,popular,bcf,articles,expenses})

I have removed the actual usernames and formatted it so that it is less ugly on StackOverflow.

Now, my question: Despite the fact that I can see these deletions executing and apparently succeeding in the log, if I go to the specified directory, the files are still there. I initially suspected permission hijinx were going on, but I've verified that I can delete the files manually by su-ing into the mongrel_AppNameGoesHere user and issuing individual rm commands or by copy/pasting the cron job to the command line. Anything that I don't manually zap stays unzapped despite days of that cron job executing successfully.

Any suggestions on to what might be happening? I was previously using Dapper Drake with these cron jobs in the /etc/crontab file directly, and when I upgraded to Hardy I moved them to user-specific crontabs (via sudo crontab -e - u mongrel_AppNameGoesHere), which was the point where they appear to have stopped working.)

+5  A: 

Problem is the {} is part of shell expanding provided by the shell, so in order to make that work, you need to change the shell that executes the cron entries.

By default /bin/sh is used so just put:

SHELL=/bin/bash

as a first row in your crontab so things should start working again.

rasjani
I wish I could upvote you a million times. Thank you.
Patrick McKenzie
@rasjani ... Nice! Sometimes I can't see the wood for the trees :P
Aiden Bell