Answer the question
In order to leave comments, you need to log in
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
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)
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 questionAsk a Question
731 491 924 answers to any question