I have an issue with my rc.local, which isn't running automatically the command line contained inside, on server boot. However, running manually rc.local works fine and starts the script.
Operating System: Ubuntu 20.04.2 LTS
Here is my rc.local
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. sh '/home/[user]/azerothcore-wotlk/reboot.sh' exit 0
And my reboot.sh
#!/bin/sh /usr/bin/screen -AmdS world /home/[user]/azerothcore-wotlk/acore.sh run-worldserver /usr/bin/screen -AmdS auth /home/[user]/azerothcore-wotlk/acore.sh run-authserver
Status of the rc.local service:
$ systemctl status rc-local.service ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled) Drop-In: /usr/lib/systemd/system/rc-local.service.d └─debian.conf Active: active (exited) since Wed 2021-05-19 22:01:41 IST; 2 days ago Docs: man:systemd-rc-local-generator(8) Process: 500 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS) Warning: some journal files were not opened due to insufficient permissions.
rc.local and reboot.sh both have permissions:
$ ls -l /etc/rc.local -rwxr-xr-x 1 root root 718 May 16 01:13 /etc/rc.local $ ls -l reboot.sh -rwxrwxr-x 1 [user] [user] 179 May 16 01:16 reboot.sh
By the way rc.local used to work awhile ago, but suddenly stopped for an unknown reason. I'm not an experienced Linux user, so I've read a lot of posts about this problem, and the most often recommendations was to: check if the rc.local has a shebang line (check!); Set proper permissions to rc.local and the script (check!); check the status of the service (check!).
After hitting a rock with rc.local, I decided to give a try to some other methods.
I tried with crontab:
crontab -e @reboot sh /home/[user]/azerothcore-wotlk/reboot.sh
Not starting on server boot. Starting normally if run manually.
Also tried init.d
sudo su nano /etc/init.d/reboot
chmod ugo+x /etc/init.d/reboot update-rc.d reboot defaults
Same result - not starting on boot.
Then tried to create a service:
sudo nano /usr/bin/acore.sh
#!/bin/sh screen -AmdS world /home/[user]/azerothcore-wotlk/acore.sh run-worldserver screen -AmdS auth /home/[user]/azerothcore-wotlk/acore.sh run-authserver
sudo chmod +x /usr/bin/acore.sh
sudo nano /etc/systemd/system/acore.service
[Unit] Description=My daemon [Service] ExecStart=/usr/bin/acore.sh Restart=on-failure [Install] WantedBy=multi-user.target
$ systemctl start acore.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to start 'acore.service'. Authenticating as: ,,, ([user]) Password: ==== AUTHENTICATION COMPLETE === systemctl enable mydaemon.service
systemctl enable acore.service
Not working either.
At this point I have absolutely no idea what to do. As I mentioned above, I'm not an experienced Linux user, so any help will be appreciated!
Edit: As @terdon suggested, I added the lines
to the beginning of the rc file)
to the beginning of the reboot script
Both files have been created in the
/tmp folder after rebooting the server.
Edit2: Thanks to @terdon the problem is solved by adding 'sleep 60' in the beginning of the rc.local.