1

I have been trying to make my fedora pc do a little script at reboot but i can't get it to work.
My script works perfectly, for example if it's 02:10 and inside crontab -e I write 11 02 * * * /path/to/my/script, then cron executes it flawlessly, but if I try to set it at boot time it simply doesn't work.

I already tried to use both my "normal" user and root user, but it doesn't help, it seems like cron doesn't like @reboot

  • What cron daemon? Not all support @reboot. – DopeGhoti Jun 4 '16 at 7:07
  • crontab... it shoul support it, right? – OverMorrow Jun 4 '16 at 8:42
  • What does the script do? Perhaps some service or daemon that it relies on is not up/ready at that point in the boot sequence? – steeldriver Jun 4 '16 at 9:42
  • It's a simple ping... "#!/bin/bash /bin/ping 8.8.8.8" – OverMorrow Jun 4 '16 at 12:04
  • 1
    So maybe networking is yet not up? what error do you get? – steeldriver Jun 4 '16 at 12:24
2

I thought that maybe as "@steeldriver" user said, the network couldn't have been ready yet when the system booted, hence I edited and added "sleep 120" before the command.
Now it is "@reboot sleep 120; /path/to/my/script.sh > /home/myuser/itworks.txt 2>&1".

It simply works, it creates the file itworks.txt and if you "cat" it, you'll get all the info.

0

You may invoke crontab as root,
crontab -e
and then insert this line

@reboot /home/myuser/bin/command.sh
where command.sh is the executable file
note: chmod 755 command.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.