Skip to main content
changed title, simpler (perhaps better for posterity)
Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54

Is there a designated place for Where do I put scripts that are (indirectly) automatically executed by systemd units?

deleted 73 characters in body
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54

Arch Linux Question (orFor 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?

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
  • systemd unit 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 by the amazing Arch Linux developers (brown nosing).

[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

Arch Linux Question (or 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?

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
  • systemd unit 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 by the amazing Arch Linux developers (brown nosing).

[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

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?

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
  • systemd unit 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
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Arch Linux Question (or 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?Where do I put my systemd unit file?

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 systemdRun 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
  • systemd unit 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 by the amazing Arch Linux developers (brown nosing).

[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

Arch Linux Question (or 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?

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
  • systemd unit 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 by the amazing Arch Linux developers (brown nosing).

[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

Arch Linux Question (or 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?

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
  • systemd unit 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 by the amazing Arch Linux developers (brown nosing).

[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
added 71 characters in body
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
Rollback to Revision 9
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
added 9 characters in body
Source Link
muru
  • 77.9k
  • 16
  • 212
  • 318
Loading
added 24 characters in body
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
added example
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
added 195 characters in body
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
adjusted content because of TMI
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
added analogous examples
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
added 46 characters in body
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
added security concern explanation
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
added 7 characters in body
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading
Source Link
Jonathan Komar
  • 7.1k
  • 8
  • 38
  • 54
Loading