Last active
April 19, 2016 23:51
-
-
Save Benoss/492c817d8dc4c087f12673d9b7b229e8 to your computer and use it in GitHub Desktop.
Simple Systemd blocking service auto start
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/etc/systemd/system/foo.service | |
[Unit] | |
#Description of the service | |
Description=foo | |
#Auto start on reboot when the target user target is availaible | |
After=multi-user.target | |
[Service] | |
#Switching the working directory (not needed, just an example) | |
WorkingDirectory=/usr/local | |
#Simple blocking call in python | |
ExecStart=/usr/bin/python -c "while 1:import time;time.sleep(1)" | |
[Install] | |
#Install as a multi user target (default) | |
WantedBy=multi-user.target | |
# need to enable the service after creating the file this will create a simlink from the service to the multi-user.target directory | |
# sudo systemctl enable foo.service | |
# Get the status of the service (should be loaded but inactive/dead) | |
# sudo systemctl status foo | |
# Start the service | |
# sudo systemctl start foo | |
# Stop the service | |
# sudo systemctl stop foo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment