Answer the question
In order to leave comments, you need to log in
How to autorun a binary file in Cron?
In crontab -e it says: @reboot /usr/local/etc/rc.d/blog .
After the reboot, the binary does not start or starts with errors. I did not find anything intelligible in the logs.
blog - an application compiled in golang, should raise the site engine with some functionality.
If you do not write anything in the cron, but run the file with the service blog start command or along the path /usr/local/etc/rc.d/blog - everything works, you can go via http.
After you register in crontab, you can’t run it on command - the application works and, as far as I understand, crashes, http is not available.
What is the problem?
Answer the question
In order to leave comments, you need to log in
Everything turned out to be simple:
in my case, when starting a cron task, I tried to start it from the root directory, and the application's static files (templates) were not picked up;
it turned out to be enough to specify the path to the directory with the file before the path to the file:
@reboot cd /usr/local/etc/rc.d/; /usr/local/etc/rc.d/blog - and everything worked
If your application is launched by service blog start, this means that you don’t need to crutch anything in the cron - it will start anyway at system startup.
And then the second question arises - what in general are you trying to achieve? What is the task?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question