Question on the fact of the similarity autoload in linux.

Works on the server php-script in the background. In DC, the server was turned off at night. How to make it so that after switching on and loading the OS, she herself would launch this script again? Probably need a command on bash, it must be saved to a file, and the file either put in some folder or run at startup. Debian 8 system

  • one
    See /etc/init.d/ - Yaant
  • 2
    Possible duplicate issue: autoload jar when starting CentOS6 - aleksandr barakin
  • In Debian 8, the default systemd initialization system is Dmitry Erohin
  • @DmitryErohin, and what does that change ? - aleksandr barakin
  • My comment was addressed to Yaant - Dmitry Erohin Nov.

1 answer 1

Create a file /etc/systemd/system/php-script-4-autostart.service with the following contents:

 [Unit] # Чисто камент для человека. Description=Autostart my php script # Запускать скрипт после того как поднимется сеть After=network.target [Service] # Хз что это, но оно пашет Type=oneshot # Не помню, но нужно для предыдущей строки. RemainAfterExit=yes # Собсно путь до скрипта. ExecStart=/path/to/php-script.php # Под каким пользователем и группой он будет выполняться. Секурность, вся фигня. User=www-data Group=www-data [Install] # Аналог Runlevel WantedBy=multi-user.target 

And then let it run at system startup:

 systemctl enable php-script-4-autostart.service 
  • one
    Fifteen lines of text and one command instead of a single line . - aleksandr barakin
  • 2
    systemd is already a standard, whether someone likes it or not. When creating a service like in my answer, you can start, stop, view the status and prohibit the download of the program \ script through standard commands. rc.local - IMHO crutch and is suitable for dirty hacks of the form: "if you plow, if you plow, then we will do it nicely." - don Rumata Nov.