0
0,35 * * * *  /home/scripts/backup.sh "daily backup"

what is wrong with my cron tab line it isn't working I didn't try @daily yet but wanted to make sure it is running so am running it at 0 minutes on the hour and at 35 mintues every hour.

I don't need to restart the server do I ?

5
  • In what way is it not working as expected ?
    – user9517
    Feb 22 '13 at 9:41
  • Traditionally, there is comment line with the column titles above the first entry. Make sure your line matches the syntax. In Ubuntu, for instance, your line would be incorrect. BTW, what distro are you using?
    – Gevial
    Feb 22 '13 at 10:08
  • @slimsuperhero: The format is correct for a user crontab but not /etc/crontab or the /etc/cron.d snippets
    – user9517
    Feb 22 '13 at 10:13
  • I am unsure of the distro. The previous entries in the crontab are for hitting urls so dont really match what I want to do. Its not working as expected because I dont see the script being called or evidence of it. As I have a message at the end I should see that in the cron log no ?
    – landed
    Feb 22 '13 at 10:40
  • @landed: take a look at serverfault.com/questions/449651/… it will almost certainly help
    – user9517
    Feb 22 '13 at 10:46
2

First make sure you the cron is being executed on time. This can be done by checking /var/log/cron. You must see execution every 0th and 30th min.

tail -f /var/log/cron

If cron is attempting the execution on time and the script isn't running yet then probably it is permission issue. Grant execute permission to the user for which you are running cron. If not sure about user thing, just gran execute to all:

chmod a+x /home/scripts/backup.sh
2
  • Which distro/OS uses cronlog ? I don't have it on my CentOS or Ubunu
    – user9517
    Feb 22 '13 at 10:17
  • Hi Lain, Its /var/log/cron not /var/log/cronlog
    – friendyogi
    Mar 19 '13 at 8:21
0

You don't need to restart the Server. As long as the cron daemon is running it should be ok.

are you sure the script is executable by the user the cronjob is running as? To mark it executable, do this chmod a+x /home/scripts/backup.sh

1
  • Ok have tried with a permission change will report back.
    – landed
    Feb 22 '13 at 10:52
0

Make sure you modified the crontab file correctly.

The correct way to edit the crontab is to run crontab -e. And the correct way to verify its content is with crontab -l.

If you modified /etc/crontab, then you may need to restart the cron service (depending on your cron version). And you need to put the username before the command. Like this:

0,35 * * * * root /home/scripts/backup.sh "daily backup"

And of course, if you are using some odd cron daemon, what I said may not be true.

2
  • Modern versions of cron check every minute for changes serverfault.com/questions/358427/…. If it is a /etc/crontab then the format is incorrect too.
    – user9517
    Feb 22 '13 at 10:12
  • yes I modified directly as this was how it has been done previously. So I will try and restart the server - isn't there a restart cron ? Thanks for your answer.
    – landed
    Feb 22 '13 at 10:39

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .