For any OS that uses systemd to manage processes and follows the Filesystem Hierarchy Standard by the Linux Foundation
I recently asked where to but a systemd unit file: Where do I put my systemd unit file on Arch Linux?
I would like to run a python script every 5 minutes (not to be confused with a systemd unit file script that calls the python script). I read the answers to this question: Run script every 30 min with systemd
This is where my question comes in. Where should or could you store scripts that are run by systemd? Is there a reserved place for these, particularly on Arch Linux?
- For example, logs are placed in
/var/log systemdunit files are placed under/etc/systemd/system
/etc/systemd/system/writehello.service
Here is an example service.
[Unit] Description=Run python script that writes hello in file on /media/5TB/hello.txt [Service] Type=oneshot ExecStart=# <-- This is what I am looking for [Install] WantedBy=multi-user.target /etc/systemd/system/writehello.timer
Here is a corresponding timer. This is all stuff documented.
[Unit] Description=test [Timer] Persistent=true OnUnitActiveSec=10s OnBootSec=10s [Install] WantedBy=timers.target /path/to/writehello.py
This is the path I am looking for.
#!/usr/bin/env python import os import datetime now = datetime.datetime.now() f1 = open('/media/mydrive/hello.txt','a') f1.write('hello %s\n' % (now)) f1.close