0

I have a cron-job, which is just a script, clearing directories, which accumulate files over time. Unfortunately, it is not firing. Any idea why. I have created the cron-job using cronmaker.com.

How do I know it was not fired, because it is set to fire every night, yet there are old files in it.

output of crontab -e

0 0 3 1/1 * ? * ./home/deploy/scripts/clearzip.sh

Thank you for your help.

Script contents :

#!/bin/bash
rm -rf /media/attachment/zip/*.*
rm -rf /home/deploy/excel/*.*
rm -rf /home/deploy/pdf/*.*
  • what you trying to achieve? simply everynight at midnight? – lese Feb 26 '16 at 10:02
  • There's a difference between 'not firing' and 'firing but doing the wrong thing, or maybe nothing at all'. – EightBitTony Feb 26 '16 at 10:02
  • @EightBitTony : If I execute the clearzip.sh manually, then its working, just not automatically. But I have made changes as per Stephens answer. – We are Borg Feb 26 '16 at 10:12
  • @WeareBorg I suspect Stephen's answer is correct, however, running a job manually doesn't mean it will work under cron. cron has a minimal environment, where the PATH for example is very different to your normal shell. Search this site for stuff runs manually but not under cron. My point was that you can't just assume it's not running because it doesn't do anything - you can solve that by adding logging to the script (if there's none at present) or by checking the cron daemon logs. – EightBitTony Feb 26 '16 at 10:15
  • 1
    @WeareBorg cronmaker is just trying to bank in on the cron name with their website hoping to attract people and getting them to use quartz, but primarily to get donations. If they would call it quartzmaker 99.9% of the people (like) you working with cron would never ever visit their website. – Anthon Feb 26 '16 at 12:39
2

CronMaker uses Quartz cron triggers, which add a couple of non-standard fields (for seconds and years). You should drop the first and last fields for standard cron, use * instead of ?, and remove the leading . from your command:

0 3 1/1 * * /home/deploy/scripts/clearzip.sh

will run every day at 3am. More idiomatically,

0 3 * * * /home/deploy/scripts/clearzip.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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