A
A
Andrew2020-02-11 17:30:56
FreeBSD
Andrew, 2020-02-11 17:30:56

How to force sh script to be loaded in FreeBSD after reboot?

Hello!

Please help with your advice!
There is FreeBSD 12. It is
necessary that my sh-script is executed once every time the system boots.
Everything seems simple, but all the methods I found do not work!
This is not a service, so starting from rc.d is not needed, the script should be loaded once.
Of course everything works manually.
The file is made executable for everyone. I tried different owners, from root:wheel to nobody:nogroup.
Doesn't start.
I tried it through cron, added the @reboot root /usr/local/etc/flash_mysql_flags.sh line to crontab (without root too)
Added lines to crontab following the advice from the Internet:
SHELL=/usr/local/bin/bash
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/etc
Doesn't work.
And of course rc.local.
Also unsuccessful!
The script needs mysql, paused before the script, to no avail.
I tried to insert the touch command into rc.local instead of the script, it does not work.
I hope for your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Chernykh, 2020-02-12
@sashkets

added @reboot root /usr/local/etc/flash_mysql_flags.sh line to crontab (without root too)

flash_mysql_flags.sh - custom script. In your mind, you need to put it in /usr/local/sbin and give execution rights
chmod 755 flash_mysql_flags.sh
create a root crontab and specify your command
crontab -u root -e
Specify the paths to the PATH variable and the desired command
@reboot flash_mysql_flags.sh
in /var/cron/allow should be root
crond (or whatever you use there, must be running)
and read the logs /var/log/cron

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question