>> One of my systems has a crontab like this to clean up and >> consolidate the output of the video monitoring app "motion": >> >> # crontab -l >> # DO NOT EDIT THIS FILE - edit the master and reinstall. >> # (/home/grant/cron.root.txt installed on Sat Sep 25 10:42:18 2010) >> # (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 >> vixie Exp $) 50 23 * * * /bin/rm /home/motion/$(date -d 'yesterday' >> +%Y%m%d)*.jpg 55 23 * * * /bin/rm /home/motion/$(date -d >> 'yesterday' +%Y%m%d)*.avi 59 23 * * * /usr/bin/mencoder >> /home/motion/$(date +%Y%m%d)*.avi -noidx -o >> /home/motion/full-$(date +%Y%m%d).avi -ovc copy -oac copy >> >> If I execute each command manually, it works great, but nothing >> happens otherwise. Can someone tell me why this crontab doesn't >> seem to be executing? > > crontab does not use the same shell you use, so when your crons run > they are missing all of the niceties you are used to using yourself. > > Things like PATH for example, and the $() may or may not work. > > You have paths for rm and mencoder but not for date
I've switched to this but I can't find the date binary. Does anyone know the full path for date? 50 23 * * * /bin/rm /home/motion/`date -d 'yesterday' +\%Y\%m\%d`*.jpg 55 23 * * * /bin/rm /home/motion/`date -d 'yesterday' +\%Y\%m\%d`*.avi 59 23 * * * /usr/bin/mencoder /home/motion/`date +\%Y\%m\%d`*.avi -noidx -o /home/motion/full-`date +\%Y\%m\%d`.avi -ovc copy -oac copy - Grant