I have a problem with my cron job.
This is my script for creating mongodb backup:
#!/bin/sh
echo "Running scheduleSpider.sh at \`date\`" >> /tmp/scheduleSpider.sh.log
DIR=`date +\%m\%d\%y`
DEST=/dbbackups/$DIR
mkdir $DEST
mongodump -h localhost:27017 -d xxx -u xxx -p xxxx -o $DEST
This is crontab -u root -e table content:
* * * * * /aamycrons/dbbackup.sh
If I run in terminal:
sh /aamycrons/dbbackup.sh
This works great its make my DB backup but cron doesn't do that, what em I doing wrong?
sh /aamycrons/dbbackup.sh
as opposed to/aamycrons/dbbackup.sh
then you didn't make the script executable. Change permissions like withchmod 755
chmod +x
is a bit simpler thanchmod 755
, and it respects your current umask. zire: if you dochmod +x /aamycrons/dbbackup.sh
, then you shouldn't need the/bin/sh
in your crontab.