Assuming that your scripts all execute properly when run manually from the command line, this should get things moving forward:
You will need two separate crontab
entries for what you want to do.
- To start at
reboot
, try this:
@reboot ( /bin/sleep 30; /bin/bash /home/pi/git/vthoang/cgminer/x1R606b.sh >> /home/pi/cronjoblog 2>&1)
- To start a script at 12 hour intervals
0 01/12 * * * /bin/bash /home/pi/git/vthoang/cgminer/x1R606b.sh >> /home/pi/cronjoblog 2>&1
A few comments:
The sleep
command may be useful for jobs executed @reboot
. It will give your system's services time to get started before attempting to execute your script. If your script doesn't depend on system services to execute successfully, it probably won't hurt to use sleep
.
The /bin/bash
assumes your script is running under bash
, and it may or may not be necessary. If you have a proper shebang in your shell script (e.g. #!/bin/bash
as the first line), it won't be needed.
You may benefit from redirecting any stderr
output from your script to a file so that you won't miss any error messages that may be generated by your script.
You mentioned starting more than one job at reboot. In the interest of simplicity, consider a separate @reboot
line for each job you want to start.
Refer to the crontab guru to help with the syntax for scheduling your jobs.
You may want to read some other Q&A here(1, 2, 3, 4) regarding the use of cron
to schedule jobs. And this recipe covers some details on the environment
under which cron
runs.
date
is in/bin
on a Pi. You should see the/tmp/rebootproof
however, but it would be empty. Try the@reboot /bin/date > /tmp/rebootproof
and you will see that that works. – Ljm Dullaart Dec 04 '19 at 21:33@reboot
-test works, then you know the problem is not withcron
. Then the next step would be why your script does not work. Try https://www.shellcheck.net/ to see if there are any issues with your script. – Ljm Dullaart Dec 04 '19 at 21:36