Good material
https://www.baeldung.com/linux/run-script-on-startup
https://www.baeldung.com/linux/systemd-multiple-parameters
https://operavps.com/docs/run-command-after-boot-in-linux/
Running commands in a subshell
#!/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.
(
cd /home/ubuntu/somefolder/
sh -e -c 'celery -A someapp.tasks worker -Ofair --loglevel=info > output.log > errors.log'
)
exit 0
Starting running services
systemctl stop my-service.service
systemctl daemon-reload
systemctl enable my-service.service
systemctl start my-service.service
Use Journalctl for looking over the servcice logs
Use the journalctl command, as in: journalctl -u service-name.service Or, to see only log messages for the current boot: journalctl -u service-name.service -b For things named .service, you can actually just use , as in: journalctl -u service-name For other sorts of units (sockets, targets, timers, etc), you need to be explicit. In the above commands, the -u flag is short for --unit, and specifies the name of the unit in which you're interested. -b is short for --boot, it restricts the output to only the current boot so that you don't see lots of older messages. See the journalctl man page
Leave A Comment?