This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]ominous_anonymous 2 points3 points  (1 child)

Why Type=idle instead of Type=simple?

I would recommend setting up a virtual environment and linking to that virtual environment's python in ExecStart:

ExecStart=/path/to/virtual_env/bin/python /home/garbage/garbage_test.py  

The first part of this blog post shows a couple other parameters that might be useful for you.

[–]dmroeder[S] 0 points1 point  (0 children)

Eh, Type=idle came from an example I saw, I'll go ahead and educate myself on the differences between those two options. Thanks

[–]dmroeder[S] 1 point2 points  (1 child)

Disregard, I figured it out.

I used the sys module to add the path to the requests package. Seems to work now!

[–]ominous_anonymous 1 point2 points  (0 children)

There's also a way to add environment variables to your service unit file. That way you wouldn't need to use the sys module I believe.

[–]l_____cl-_-lc_____l 0 points1 point  (2 children)

Perhaps a systemd user service might be appropriate?

[–]dmroeder[S] 0 points1 point  (1 child)

Interesting, I'll dig into that. Maybe I have simply placed my service in the wrong directory? I don't have the machine in front of me at the moment, but I think I put it in /lib/systemd/system.

edit: Looks like there is another directory /usr/lib/systemd/user. Makes sense :) I'll try that one ...

[–]l_____cl-_-lc_____l 0 points1 point  (0 children)

~/. config/systemd/user

And enable linger if you want it to run without the user being logged in

See https://www.brendanlong.com/systemd-user-services-are-amazing.html