Tuesday

run python script as ubuntu service

step 1 - create service file here is archivebot.service I created for my server
   

[Unit]
Description=archivebot

[Service]
ExecStart=/bin/bash -c "cd /home/al/slack-archive-bot;export SLACK_API_TOKEN=TOKEN_HERE && python archivebot.py"

[Install]
WantedBy=multi-user.target
Then I did everything according to this example :

Step 1: I created this file (note location) which essentially fires a bash process with an extended argument. You could fire your own command which could be different from bash.

   

[root@y500-fedora ~]# cat /etc/systemd/system/foo.service 
[Unit]
Description=foo

[Service]
ExecStart=/bin/bash -c "while true; do /bin/inotifywait -qq --event close_write /sys/class/backlight/acpi_video0/brightness; su myusername -c '/bin/xbacklight -display :0 -set $(cat /sys/class/backlight/acpi_video0/brightness)'; done"

[Install]
WantedBy=multi-user.target

Step 2:

Reload systemd:

systemctl daemon-reload

Start the new service:

systemctl enable foo

(similarly you can disable it)

(optional) Step 3: It should start automatically at next reboot into multi-user mode (run level 3) but if you want to start it right away:

systemctl start foo
systemctl status foo # optional, just to verify

Update: For completeness, I should add that ubuntu bionic seems to have a very thorough man page. RTFM here

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...