Systemd: Difference between revisions

From Anthony Pastor Wiki Notes - Verba volant, scripta manent
Jump to navigation Jump to search
No edit summary
No edit summary
Line 22: Line 22:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl enable my-bash-script
systemctl enable my-bash-script
</syntaxhighlight>
=Disable Systemd log redirection (useful to debug)=
<syntaxhighlight lang="bash">
_SYSTEMCTL_SKIP_REDIRECT=true bash -x /etc/init.d/mysql start
</syntaxhighlight>
</syntaxhighlight>

Revision as of 15:17, 24 February 2016

Configure a Bash script to run as a service

$ cat /etc/systemd/system/my-bash-script.service 

[Unit]
Description=Basic Script Example
After=network-online.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/home/my-script/my-script.sh

[Install]
WantedBy=multi-user.target


systemctl enable my-bash-script

Disable Systemd log redirection (useful to debug)

_SYSTEMCTL_SKIP_REDIRECT=true bash -x /etc/init.d/mysql start