W
W
wargych2018-03-26 12:31:46
go
wargych, 2018-03-26 12:31:46

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

3 answer(s)
W
wargych, 2018-03-26
@wargych

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

A
athacker, 2018-03-26
@athacker

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?

R
Roman, 2018-03-28
@KirEv

it is better to raise such things as a service,
with half-trouble paths, problems will be added with open descriptors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question