S
S
smartup2015-01-06 17:09:06
CentOS
smartup, 2015-01-06 17:09:06

What is the correct way to run a script once after boot in CentOS 7?

Friends, hello. There is a docker container with CentOS 7 inside. There, instead of fakesystemd, a real systemd is raised. But there are no extra services there (even cron) and should not be. In general, it works well. But after launching this container, it became necessary to execute a small script in it. The script should NOT be made a daemon, i.e. it should start, work and rest quietly until the next reboot.
The manuals that I googled suggest adding a script to /etc/init.d just turn it into a service. Is it possible somehow without it?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Petrikov, 2015-01-06
@RicoX

Prescribe in
/etc/rc.local

S
SagePtr, 2015-01-06
@SagePtr

And what prevents the service from working out and completing its work? Services are not monitored and a dead service is not automatically restarted, so the script in init.d will be executed only at system startup and shutdown (but nothing prevents checking the first parameter, and if it is not "start" - not executed)

E
Eugene, 2015-01-06
@Nc_Soft

screen

V
Vlad Zhivotnev, 2015-01-06
@inkvizitor68sl

So enta.
#!/bin/sh
run_your_command &
run_your_normal_docker_application
docker -d ubuntu:14.04 "/path/to/sh/file"
Don't forget to chmod +x when building the shab.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question