A
A
Anton2020-01-23 21:19:15
linux
Anton, 2020-01-23 21:19:15

How to add a command to execute after a server restart?

Installed Dante SOCKS5 server on ubuntu 16
After rebooting via Putty as root, I execute the command

/home/dante/sbin/sockd -f /home/dante/danted.conf -D

How can I do it automatically after restarting the server?
Added to cron with the last line,
/etc/crontab does not work
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
@reboot root /home/dante/sbin/sockd -f /home/dante/danted.conf -D
#

Answer the question

In order to leave comments, you need to log in

6 answer(s)
D
Dmitry Shitskov, 2020-01-23
@Zarom

https://habr.com/ru/company/southbridge/blog/255845/

D
Dr. Bacon, 2020-01-23
@bacon

How were they set? If through apt, then during installation, the script for autorun should also be installed. Well, one way or another, write a service for systemd yourself.

A
Andrey, 2020-01-23
@VELIK505

Added to cron with the last line,
/etc/crontab does not work

It's better to add the command to /var/spool/cron/crontabs/ root
and make sure that the file (root) has an empty line at the bottom!

R
Radjah, 2020-01-24
@Radjah

Writing a unit for systemd is best. After all, it's a demon.
> Installed on ubuntu 16
LTS like 18.04

K
Karpion, 2020-01-24
@Karpion

Do you need to run this once or always after system startup?
In the second case, you need to start as all daemons like Apache start. About FreeBSD, I would answer - I know where the start scripts are.

A
Anton, 2020-01-24
@anton99zel

Reinstalled OS on 18.04, installed dante from apt. Issue resolved. Thanks to all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question