date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,461,408,431,000 |
The btrfs-scrub manpage says:
The user is supposed to run it manually or via a periodic system
service. The recommended period is a month but could be less.
For systemd users how is this automated, capturing all output in the journal?
I am running Manjaro based on Arch Linux.
|
Being a virtuously lazy sysadmin, I came up with the following which will start and enable the [email protected] on all currently mounted btrfs filesystems:
awk '$3=="btrfs" { system("systemd-escape " $2 "| cut -c2-") }' /etc/fstab | while read -r fs; do
[[ -z $fs ]] && fs=- # Set to '-' for the root FS
sudo s... | Periodically running btrfs-scrub |
1,461,408,431,000 |
I have the following unit enabled and started
[Unit]
Description=Schedule a nightly execution at 03.15 for Backup ROOT
# Allow manual start
RefuseManualStart=no
# Allow manual stop
RefuseManualStop=no
[Timer]
#Execute job if it missed a run due to machine being off
Persistent=false
# Run every night 03.15
OnCalendar=... |
This is very well answered by this answer to Prevent systemd timer from running on startup.
I will summarize
The problem is that I have always included something like
WantedBy=basic.target in the [Install] section of the .service file
(because its part of the standard systemd service copy pasta). It
turns out this a... | OnCalendar systemd timer unit still executes at boot, how to stop it? |
1,461,408,431,000 |
I'm looking for a systemd timer to run every 1 hour and 18 minutes but I have this only lead.
systemd-analyze --iterations=3 calendar *:0/18 which is every 18 minutes.
|
For a monotonic timer that runs at regular intervals (e.g. every X minutes and Y seconds, every X days and Y minutes etc) you have to define a starting point and a repetition value. This can be accomplished by using two directives in the [Timer] section.
The settings and their their starting points are explained in sy... | systemd timer every 1 hour and X minutes? |
1,461,408,431,000 |
When we issue "systemctl status", we usually get in the output, a line showing the status and for how long it has been in that status.
Like: (I issued that few minutes ago)
Active: active (running) since Wed 2023-11-22 01:56:06 CST; 10h ago
However, it happened to get the following line for the same service when the ... |
You probably have hit this Systemd bug which occurs when your RTC is set to the local time (timedatectl will confirm this).
Either upgrade Systemd or set your RTC to UTC:
# timedatectl set-local-rtc 0
The latter is preferable. Quoting the timedatectl manual:
Note that maintaining the RTC
in the local timezone is not... | Why systemctl status shows a time in the future and the amount of time left? |
1,461,408,431,000 |
So I have my service unit (runs some node code) and my timer unit
Service:
[Unit]
Description=foo
[Service]
Type=oneshot
ExecStart=/home/ubuntu/services/foo/start.sh
Timer
[Unit]
Description=foo timer
[Timer]
OnBootSec=0min
OnCalendar=*-*-* 05:01:00 UTC
Unit=foo.service
[Install]
WantedBy=multi-user.target
I u... |
From systemd.timer(5):
If a timer configured with OnBootSec= or OnStartupSec= is already in the past when the timer unit is activated, it will immediately elapse and the configured unit is started. This is not the case for timers defined in the other directives.
Since your timer unit sets OnBootSec=0min, it will alw... | systemctl start foo.timer also starts foo.service even though the OnCalendar criteria hasn't been met |
1,461,408,431,000 |
I want to bind a user systemd timer (or service) to network events. For example consider this service:
[Unit]
Description=shows if connection changed
[Service]
Type=oneshot
Environment=DISPLAY=:0
ExecStart=notify-send "Network" "Status changed!"
How can I force this user service to run on network up/down events?
I a... |
Run systemctl --user without any other parameters to see a listing of all units the user-level services can interact with. You will probably find something like sys-subsystem-net-devices-eno1.device.
But note that this might not be the optimal way to react on network status changes: instead, you could drop a script in... | How to bind a user-level systemd service to network events? |
1,461,408,431,000 |
After trying the solutions posted here (Prevent systemd timer from running on startup), I thought I had my systemd timer problems corrected. However, after my last reboot, my service fired off during boot (evidently making up for a missed event).
Here are the files in question:
btrfs_backup.timer
[Unit]
Description=Cr... |
Try taking the Requires=btrfs_backup.service out of the timer.
The systemd.unit(5) man page says Requires= will activate the requirements as well.
So activating the Timer will activate the requirement of btrfs_backup.service.
| Trying to stop systemd timers from triggering missed events |
1,461,408,431,000 |
I have a very weird issue on Debian Buster. I've enabled unattended-upgrades on the server as this is a very bare bones server and it should just update automatically. However, it seems that the apt timers for this never start.
When I check all timers, I get the following:
# systemctl list-timers
NEXT ... |
Found my issue, I needed to upgrade systemd. Which is what the jobs were supposed to do, of course...
| Systemd timers will not fire |
1,461,408,431,000 |
I'm trying to run a systemd timer every minute as a user, but it isn't repeating after the initial trigger. The ffmpeg-timelapse.timer is configured with the OnCalendar=minutely to fire every minute, and the ffmpeg-timelapse.target is WantedBy the dependent services. This allows me to easily add/remove cameras from th... |
I determined the issue by looking at the systemctl --user list-units --all ffmpeg* output. The ffmpeg-timelapse.target was remaining loaded/active/active. Prior to the actual triggered event the ffmpeg-timelapse.timer have the SUB set to waiting.
UNIT LOAD ACTIVE SUB JOB DESC... | systemd User Timer Not Repeating |
1,461,408,431,000 |
Say I want a a program to be active between 12:00h and 13:00h on a desktop machine (i.e. if PC is on at either time cannot be guaranteed). I'll assume I can use systemd units for this.
Starting service A with a timer and accounting for poweroff times is simple:
A.timer
[Timer]
Unit=A
OnCalendar=*-*-* 12:00:00
Persiste... |
I had the same requirements.
I can confirm that two timers catching up at boot result in a race condition, with a random outcome.
And what about a scenario where the system reboots more than once between 12 and 13. Persistent may not be of any help in that case.
My conclusion (but I would love to be proven wrong) is t... | systemd timer: enable service for specific time ranges only |
1,588,094,392,000 |
I have a systemd service+timer that I'd like to install which does not match my packagename.
# debian/mypackage.myscript.timer
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target
# debian/mypackage.myscript.service
[Service]
ExecStart=/usr/bin/myscript
# debian/rules
%:
dh $@
overrid... |
Treat the *.service and *.timer independently by explicitly defining the unit file:
override_dh_installsystemd:
dh_installsystemd --name=myscript myscript.service --no-start
dh_installsystemd --name=myscript myscript.timer
| Install systemd timer + service silently with dh_installsystemd |
1,588,094,392,000 |
Summary
A systemd service unit that is disabled ("static") and is only supposed to be triggered by a timer is run on every reboot.
Background
This was a service unit (in /etc/systemd/system/) that previously had an [Install] section and was systemctl enabled.
The [Install] section was removed and the service disabled.... |
Okay, in the process of writing this up I noticed a Requires=mysql_tzinfo.service in the [Unit] section of my timer unit.
It occurred to me that the starting of the timer at boot (dependency resolution by systemd) might be starting the service due to this Requires. Sure enough, removing this line from the timer and r... | disabled/static systemd service unit is always started at reboot (systemd timers as cron replacement) |
1,588,094,392,000 |
As an example, take the phpsessionclean schedule. The cron.d file for this looks like this:
09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi
It's saying if systemd doesn't exist on the system run the script /usr/lib/php/sessionclean.
... |
You could be looking in the wrong place. Units can be in several places.
$ systemctl cat systemd-tmpfiles-clean.service
# /lib/systemd/system/systemd-tmpfiles-clean.service
...
(you can also see a command here:
$ systemctl status systemd-tmpfiles-clean.service
● systemd-tmpfiles-clean.service - Cleanup of Temporary ... | How to see what command is being run by a systemd .timer file? |
1,588,094,392,000 |
I have two service oneshots:
one that creates snapshots
one that sends snapshots
The second one (send) should always be executed after the first one (create) is finished. Currently the services, which are of type oneshot, run at the same time.
The services are defined as follows (the exact used command from the foll... |
Your primary question seems to be how to start a second systemd service immediately after a first one was successfully started. It doesn't state what to do in case the pyznap.service is finished but the pyznap-send.service lacks the network connection to actually send the snapshots, so I will assume that you don't int... | Activate two "oneshot" services from one systemd timer so that they are started one after another |
1,588,094,392,000 |
It is possible to run a timer every 15 minutes like so:
OnCalendar=*:0/15
Is there a way to run that timer every second Monday?
|
While as of the time of writing this is still an outstanding issue, it is possible, as per this post, run action every 1st and 3rd Monday of the month. This was good enough for my needs, although is likely to leave a 3 week gap at the end of the month.
Mon *-*-01..07,15..21 02:00:00
This matches every Monday between ... | Systemd timer every second Monday? |
1,588,094,392,000 |
I have systemd unit file, I know it can be restarted on failure by providing parameters, like :
Restart=always
RestartSec=90
It will restart after 90 seconds whenever it fails,
But, I want to restart only if system time is in between given time-frame, say between 08:00 and 17:00, only then restart.
Is there way to do... |
Thanks for the suggestions and your time.
I achieved this via systemd service with
Restart=always
and two crontab entries as suggested by @JdeBP
one to start at 08:00
other to stop at 17:00
| restart systemd service within a timeframe |
1,588,094,392,000 |
i need a service to start every minute between 09:15 - 17:15.
Whats the best way to achieve this?
I could make 3 timers, one to start (1) the timer (2) which runs the service every minute and one to stop it (3). but then it wouldn't be robust for reboots in between.
|
You can create a single timer unit with multiple OnCalendar= settings, which will allow you to specify the exact interval you want.
If you look at the man page for systemd.timer, the OnCalendar= section says:
May be specified more than once.
So use three separate settings for the start, middle and end:
[Timer]
OnCal... | Systemd timer every minute between 09:15 - 17:15 [duplicate] |
1,588,094,392,000 |
I'm creating a debian package which comprises of a service and some shell scripts and would like to also install a timer in the /lib/systemd/system folder so that the service will get called periodically.
According to the debian helper guide
https://manpages.debian.org/testing/debhelper/dh_systemd_enable.1.en.html
thi... |
For automatic timer support, you need dh_installsystemd, which is available in debhelper compatibility levels 11 and up. You should use level 12 or above. Specify this in your control file:
Build-Depends: debhelper-compat (= 12)
Delete the compat file, and change your rules to omit the explicit systemd sequence:
%:
... | How to include and install debian/package.timer file inside deblan package, alongside the package.service |
1,588,094,392,000 |
I am trying to use systemd timers to change my background wallpaper and it doesn't seem to be doing what I want.
Blelow I have listed the relevant files and outputs that I have.
bgchange.timer
[Unit]
Description=Timer for background change
[Timer]
OnUnitActiveSec=10sec
OnActiveSec=5sec
OnBootSec=1sec
Persistent=true
... |
You should run those as user service/timer... You would then not need to set the DISPLAY in the service file e.g.
[Unit]
Description=Change background image periodically
[Service]
ExecStart=/home/emobe/scripts/changebg.sh
should be enough. systemd user files usually go in ~/.config/systemd/user/ so place them there
... | Using systemd timer to change the background wallpaper |
1,588,094,392,000 |
I am fairly new using systemd timers, and I am having some issues.
I am trying to schedule a script that runs daily, every 8 hours, at 6 AM, 2 PM, and 10 PM. The time starts correctly, and it shows the next scheduled time to run (which it does), but then it never seems to run the 3rd (or any other) time. What am I doi... |
OK, I believe the problem is with the script.service file. According to the systemd.timer man page:
DESCRIPTION
Note that in case the unit to activate is already active at the time the timer elapses it is not restarted, but simply left running. There is no concept of spawning new service instances in this case.... | systemd timer every 8 hours |
1,588,094,392,000 |
I wrote a very simple script (checkaudio.sh) that publishes a message from a file on a mqtt topic. I would like the script to run continuously (I would be happy even with every second). I first tried with cron, which is technically possible but "dirty" as a solution (multiple cron jobs with a 1 second delay each).
I h... |
Your .timer unit (not the .service unit, which has one but probably shouldn't) is missing an [Install] section.
You probably want to add:
[Install]
WantedBy=timers.target
Your .service file is intended to be activated only by the timer, not directly during boot (etc.). So it shouldn't have an [Install] section (and s... | How to continuously run a script with systemd |
1,588,094,392,000 |
I use OnUnitActive property which will run each N secods using last activation time of service as starting point, but i want it always run once when timer started and use 'OnUnitActive' property after.
How can i force this behavior?
|
Add an extra directive OnActiveSec=0s to the [Timer] stanza.
The systemd maintainer explains how this works.
| Start service on timer start and each N seconds after |
1,588,094,392,000 |
I've set up a systemd timer to trigger a service every minute on Ubuntu 22.04, but I'm encountering an issue where the execution time of the service significantly increases after the first run. The service simply logs some text using /bin/echo. Here are the details:
Service file (testA.service):
[Unit]
Description=Sam... |
Thanks to @AlexD for the hint. Adding the AccuracySec= option to the timer makes the magic of running the service in the right time every run.
| Ubuntu systemd service with timer is slow |
1,588,094,392,000 |
I have myscript.service and I want this service to start every hour.
So I wrote myscript.timer
Description=My script timer
[Timer]
OnCalendar=hourly
;OnCalendar=*-*-* 0/2:00:00
[Install]
WantedBy=timers.target
I started systemctl enable --now myscript.timer, then systemctl status myscript.timer
And I got
[user@loca... |
Unfortunately, I'm not reproducing the issue you're seeing. Judging by the commented ;OnCalendar=, you've been changing the field. Are you sure that you used systemctl daemon-reload between the edit and starting the timer?
When I test it out on my system I see:
$ systemctl --user cat mytime.timer
# /home/stew/.confi... | How systemd timer work? |
1,588,094,392,000 |
I would like to set up a Timer which will stop a service, execute a script and restart the service.
One of the possibilities is to use
Type=oneshot
ExecStartPre=/bin/systemctl stop myservice
ExecStart=/usr/local/bin/myscript.sh
ExecStartPost=/bin/systemctl start myservice
Another one is to have myscript.sh handling ... |
By (ab?)using the WatchdogSec the service will terminate when it fails to acknowledge within the time. It will then restart, but execute the script first.
WatchdogSec={interval}
Restart=on-watchdog
ExecStopPost=/script.sh
ref: WatchdogSec
Having the service being able to be backed up while running would be a much nic... | How to stop a service before executing an ExecStart entry? |
1,588,094,392,000 |
I'd like to use systemd timers to send emails periodically to remind me of certain things like anniversaries or filing taxes.
I send my regular emails with Mutt; it would be nice if I could reuse that to send the automated emails, and not having to install additional software like Sendmail.
I'm on Arch Linux 4.18.5, s... |
First, create a systemd service file at ~/.config/systemd/user/send-mail.service with the following contents:
[Unit]
Description=Sends mail that reminds me of an anniversary
[Service]
; The l flag for bash creates a login shell so Mutt can access our environment variables which contain configuration
ExecStart=/bin/ba... | Send email periodically with systemd |
1,588,094,392,000 |
I have a realtime timer with Persistent=false running immediately after boot although my objective is to run it periodically!
I saw it is a rather common question but none of the answers I found in StackExchange solved my issue. I followed the advices of this post and this post.
Here I report a simplified example to r... |
Eureka!
The issue was that I hadn't initialized the time correctly.
Yes I followed this post but I used a script that wrapped the /sbin/hwclock --hctosys --utc --noadjfile command, delaying it in time. This let the boot sequence to start already creating a mess with the OnCalendar= entry (as described in the timer man... | How to avoid systemd periodic realtime timer running at boot |
1,588,094,392,000 |
I have a nodejs gui program (does not requires user interaction), which needs to be run at every 40th minutes at each hour. Say run at 05:40PM, 06:40PM, 07:40PM and so on. In a Debian server, I have enabled a systemd timer using:
systemctl --user enable my_program.timer
Problem is, scheduling starts at the given time... |
Let's focus on one question here: the duplicate runs each hour. You've used this syntax for it:
OnCalendar=*-*-* *:40:*
According to man systemd.time, the wildcard in the seconds place means it matches every second of the 40th minute of every hour. You can confirm this with the included systemd-analyze tool, which ha... | Systemd timer running scheduled service 2 times in a row, instead of running only 1 time |
1,588,094,392,000 |
I was trying to create a simple(ish) way to detect whether my laptop lid was closed and activate i3lock when it is. I know that this can be done through acpid or other methods, but I wanted to learn more about systemd timers anyway, so I went that way. It turns out that systemd has special units for timers, and one of... |
sleep.target is a target, so you name it in a WantedBy setting in your service unit file, and then enable the service.
Further reading
"Sleep hooks". Power management. Arch wiki.
| How to use systemd special units |
1,461,828,600,000 |
I have a problem where on rare occasions my Type=simple systemd service hangs or gets caught in a loop. This causes its timer to stop scheduling the service because, as confirmed with sudo systemctl status myservice, the service is still running when it should have long exited. I haven't yet figured out the bug but ... |
TimeoutStartSec should be used. As @muru mentioned in the comment, the correct way to run a script that should exit is to use Type=oneshot instead of Type=simple.
For example, if your script is normally executed in under 10 seconds, your config would be:
[Service]
Type=oneshot
TimeoutStartSec=10
SyslogIdentifier=myser... | How can I specify a maximum service duration in systemd service? |
1,461,828,600,000 |
I have multiple Redhat & CentOS 7 servers that are used only during working hours. I am looking into using the systemd-shutdownd service to shut down each machine at 6-30pm on workdays.
Systemd appears to be a cleaner solution than cron jobs.
Google shows that there is a schedule file that this service uses, but I ha... |
CentOS 7 had systemd init system.
systemd has a good feature which is named as timer. Timer is like service and is intended for starting services at specific time. systemd shutdown system by calling systemd-poweroff service. So it's need to write systemd-poweroff.timer:
$ cat /etc/systemd/system/systemd-poweroff.timer... | Use systemd-shutdownd schedule |
1,461,828,600,000 |
"On Boot" is ambiguous to me. Does it mean when booting starts, when booting finishes, mid boot, when timer.target is met? The documentation that I've read doesn't resolve this ambiguity.
|
OnBootSec= is relative to the boot time, as given by the kernel — basically, the time at which the kernel started execution. See the relevant lines in systemd.
The table of directives in man systemd.timer hints at this in its description of OnStartupSec=:
For system timer units this is very similar to OnBootSec= as t... | When does the timer for 'OnBootSec' in a systemd timer unit actually start? |
1,461,828,600,000 |
I'm having hard time figure out the format to run every hour on the :50 minute mark.
I've tried:
OnCalendar=00/0:50
But it
Timer unit lacks value setting. Refusing.
|
You can find detailed description how to specify time for timer unit in man systemd.time:
Examples for valid timestamps and their normalized form:
hourly → *-*-* *:00:00
So I guess the value you want to put there is:
*-*-* *:50:00
Also:
Either time or date specification may be omitted, in which case the current da... | Systemd timer run on XX:50 |
1,461,828,600,000 |
I am trying to get a simple systemd service to run on a timer unit. For some reason, systemd doesn't seem to like the way I am specifying time. The script worked when I used minutely or daily as the value for OnCalendar, but now I want to set it to 5 minutes and systemd gives an error:
/etc/systemd/system/backup.timer... |
5m is a time-span. OnCalendar= expects a time-stamp.
According to systemd.time(7), a time-stamp is a unique point in time, while a time-span is a duration.
If you want to keep OnCalendar=, then use a time-stamp like:
minutely, hourly, daily
2012-11-23 11:12:13
Mon,Fri *-01/2-01,03 *:30:45
If you do want to use a du... | systemd: Failed to parse calendar specification, ignoring: 5m |
1,461,828,600,000 |
I want a timer for a specific day (every year specific month and day) repeating every 8 hours on that day (birthday reminder).
I have tested several including:
[Unit]
Description=Tom Birthday
Requires=Tom_Birthday.service
[Timer]
Unit=Tom_Birthday.service
OnCalendar=*-10-2 00/8:00
[Install]
WantedBy=timers.target
N... |
Since your computer is presumably not running in 1998, you can’t use that; if you don’t specify the year, it works:
$ systemd-analyze calendar "10-2 0/8:00"
Original form: 10-2 0/8:00
Normalized form: *-10-02 00/8:00:00
Next elapse: Sat 2021-10-02 00:00:00 CEST
(in UTC): Fri 202... | systemd timer every X hours on a specific day |
1,461,828,600,000 |
I have a Golang binary that runs every 5 mins. It is supposed to create & update a text file which needs to be write restricted. To run this binary I created a systemd service and a systemd timer unit. Systemd service uses a DynamicUser. To achieve access restriction i use CacheDirectory directive in systemd so that o... |
CacheDirectoryMode=644
This allows to read the directory list. Not to interact with a file within this directory list: the eXecute bit is required to further traverse the path and access files within the directory. This makes the write access for user monitor also useless.
Change this parameter into:
CacheDirectory... | Systemd executable failed to read file from CacheDirectory with Permission Denied |
1,461,828,600,000 |
I currently have this timer:
[Unit]
Description=Schedule wallpaper rotation
[Timer]
OnCalendar=*-*-* *:00:00
Persistent=true
[Install]
WantedBy=graphical-session.target
Which runs this service:
[Unit]
Description=Rotate wallpapers
[Service]
Type=oneshot
ExecStart=%h/bin/wpman %h/docs/media/wallpaper/arkady
Which ... |
FWIW, I'm not running any desktop environment, just X and a window manager. I'm not sure if that effects how graphical-session.target is triggered.
It does – the .target needs to be explicitly started by your ~/.xinitrc (or by your WM's "autostart").
graphical-session.target is not started automatically by Xorg for ... | How do you create a systemd user timer that will start only after X has started? |
1,461,828,600,000 |
Can anyway tell me where is the document for "AccuracySec=0" of systemd-timer? The most closed document I found is "AccuracySec=1us". I know the meaning of AccuracySec but just want to be sure that AccuracySec=0 means most accurate.
|
It's in man systemd.timer
AccuracySec=
Specify the accuracy the timer shall elapse with. Defaults to 1min. The timer is scheduled to elapse within a time window starting with the time specified in OnCalendar=, OnActiveSec=, OnBootSec=, OnStartupSec=, OnUnitActiveSec= or OnUnitInactiveSec= and ending the time configur... | systemd-timer: undocumented "AccuracySec=0" |
1,461,828,600,000 |
Can multiple instances of Unit= exist in a systemd.path or systemd.timer unit? Or, must one instead specify multiple instances of the path or timer unit, each with a single instance of Unit=? I haven't been able to find or derive any guidance elsewhere.
The former obviously is easier.
The specific application is to ... |
man systemd.timer says:
Unit=
The unit to activate when this timer elapses. The argument is a unit name, whose suffix is not ".timer". If not specified, this value defaults to a service that has the same name as the timer unit, except for the suffix. (See above.) It is recommended that the unit name that is activated... | Multiple Instances of Unit= in Path or Timer Unit? |
1,461,828,600,000 |
(x-mas.service)
[Unit]
Description=Celebrate X-Mas
[Service]
Type=simple
ExecStart=/usr/sbin/x-mas-day
[Install]
WantedBy=multi-user.target
(x-mas.timer)
[Unit]
Description=Add "X-Mas" to the calendar
[Timer]
OnCalendar=*-12-25 00:00:00
Unit=x-mas.service
[Install]
WantedBy=timers.target
(buy-presents.service)
[... |
I'm gradually starting to understand systemd.unit(5). The Before= and Requires= options only refer to the [Unit] level settings and have no bearing on any configuration on the [Timer] level. Except for inputting a systemd.time(7)-conforming value setting into the [Timer] unit, this cannot be done without assistance fr... | Is there a way to schedule a lazy timer relative to another timer? |
1,461,828,600,000 |
In my system I have b.service activated by b.timer. I want another service (a.service) that start before b.service. I cant change b.service or b.timer because are not mine. I've putte Before=b.service in a.service but the timer start b.service without starting a.service.
|
You can mark a.service as RequiredBy b.service.
Make a.service look like:
[Unit]
Before=b.service
[Service]
Type=exec
ExecStart=...
[Install]
RequiredBy=b.service
And then:
systemctl enable a.service
Now whenever b.service starts -- either via a timer or via systemctl start -- your new a.service will start first.
| systemd unit "Before=" with timer |
1,461,828,600,000 |
I wanted a "more stupid" version of crontab: Run only on given times, don't catch up after suspension.
I.e. when a service should have been triggered by crontab, but the machine was suspended, it was triggered right after resuming. That's what I didnt' want.
I solved this by writing a systemd.timer unit (instead of cr... |
After several tests, also Persistent=boolean didn't do the job. So far, I totally forgot about /etc/crontab and all times used crontab -e just to get the problems with anachron which leaded to the systemd configuration you see above and therefore this thread at all.
But adding the job to /etc/crontab does the job with... | systemd.time - OnCalendar= unwanted running after suspend |
1,461,828,600,000 |
I have a simple systemd service and timer under ~/.config/systemd/user for building nightly images of my favorite program:
# ~/.config/systemd/user/kicad-build.service
[Unit]
Description=KiCAD nightly builder
[Service]
Type=simple
StandardOutput=null
ExecStart=/bin/bash /home/jan/kicad-nightly-builder/build.sh
# ~/.... |
Your system is running a systemd version which is too old compared to the version of systemctl. (This D-Bus method was added in systemd v253.)
Use systemctl [--user] daemon-reexec to upgrade the running systemd version.
| Can't disable systemd user timer, Unknown method DisableUnitFilesWithFlagsAndInstallInfo |
1,461,828,600,000 |
My .timer file located in ~/.config/systemd/user doesn't show in output of systemctl --user list-timers --all command unless i enable it. Is it normal for this command to not show disabled .timers alongside enabled ones?
I cannot enable the .timer without an [Install] section because of The unit files have no install... |
Since the time i've asked this question, i've red more and found out that my question was lying on a misconception from my side - i thought that both systemd's user and system instances rely on the same set of targets. According to THIS page each systemd instance uses its own set targets, so it's clear that the user t... | Should i use default.target or timers.target value for WantedBy for a systemd user timer? [duplicate] |
1,461,828,600,000 |
How do the systemctl timer works when the computer is turned off at the given trigger time?
There is the option "Persistent", but when exactly is the command executed?
In how far is it guaranteed that the command will be safely executed, e.g. that a maximum of given time shall not pass between two executions?
status:
... |
It seems not to work, when the computer is turned off or no internet connection, it will not catch up as the message still says:
$ systemctl --no-pager status mintupdate-automation-upgrade.timer
...
Trigger: Tue 2021-02-02 00:32:40 CET; 13h left
So the update process (at least using this method, maybe in contrast to ... | systemctl Persistent timer and service, when computer turned off |
1,461,828,600,000 |
I want to create a timer that fires, completes execution, waits for 30 seconds and fires again but only during night hours. So far I got this:
[Timer]
OnUnitInactiveSec=30s
OnCalendar= * - * - * 23,24,00,01,02,03,04,05,06,07:*
But I don't know if the 2 conditions act as an "and" or as an "or", in other words, I don't... |
according to systemd.timer:
Multiple directives may be combined of the same and of different types, in which case the timer unit will trigger whenever any of the
specified timer expressions elapse. For example, by combining OnBootSec= and OnUnitActiveSec=, it is possible to define a timer that elapses
in regular inte... | Mixing conditions in Linux timer |
1,461,828,600,000 |
I want to start a command (unison) every 5 min as a systemd.service via a systemd.timer unit. The '.service' file alone runs fine. However when it's started by the timer unit, it runs multiple times and stops with these errors: Start request repeated too quickly. and Failed with result 'start-limit-hit'. But why?
I... |
For the record: OnCalendar=*-*-* *:0/5:* is simply wrong. OnCalendar=*-*-* *:0/5:00 does stoping the multiple execution.
| Systemd Service/Timer -- Oneshot service w/ timer executes multiple times and failed w/ 'start-limit-hit' |
1,510,565,833,000 |
On my Archlinux system, the /usr/lib/systemd/system/mdmonitor.service file contains these lines:
[Service]
Environment= MDADM_MONITOR_ARGS=--scan
EnvironmentFile=-/run/sysconfig/mdadm
ExecStartPre=-/usr/lib/systemd/scripts/mdadm_env.sh
ExecStart=/sbin/mdadm --monitor $MDADM_MONITOR_ARGS
I suspect (confirmed by some... |
This is documented in systemd.exec:
EnvironmentFile=
[...]
The argument passed should be an absolute filename or wildcard expression, optionally prefixed with "-", which indicates that if the file does not exist, it will not be read and no error or warning message is logged.
And in systemd.service:
ExecStart=
…
For... | Documentation of =- (equals minus) in systemd unit files |
1,510,565,833,000 |
I'm trying to set up watchman as a user service.
I've followed their documentation as closely as possible. This is what I have:
The socket file:
[Unit]
Description=Watchman socket for user %i
[Socket]
ListenStream=/usr/local/var/run/watchman/%i-state/sock
Accept=false
SocketMode=0664
SocketUser=%i
SocketGroup=%i
[In... |
I was running into the same issue. Googling I found this thread: https://bbs.archlinux.org/viewtopic.php?id=233035
The problem is with how the service is being started. If you specify the user/group in the unit file then you should start the service as a system service.
If you want to start the service as a user servi... | Failed to determine supplementary groups: Operation not permitted |
1,510,565,833,000 |
Some applications, like ssh have a unit file that ends with @, like ssh.service and [email protected]. They contain different contents, but I cannot understand what exactly is the difference in functionality or purpose.
Is it some naming convention I'm not aware of?
|
As others have mentioned, it's a service template. In the specific case of [email protected], it's for invoking sshd only on-demand, in the style of classic inetd services.
If you expect SSH connections to be rarely used, and want to absolutely minimize sshd's system resource usage (e.g. in an embedded system), you co... | Why do some unit filenames end with @? |
1,510,565,833,000 |
I have a question regarding making my own unit (service) file for Systemd.
I've read the documentation and had some questions. After searching around, I found this very helpful answer that gives some detail about some of the questions I was having.
How to write a systemd .service file running systemd-tmpfiles
Although... |
The systemd manual discusses the relationship between Before/After and Requires/Wants/Bindto in the Before=, After= section:
Note that this setting is independent of and orthogonal to the
requirement dependencies as configured by Requires=, Wants= or
BindsTo=. It is a common pattern to include a unit name in bot... | Systemd Unit File - WantedBy and After |
1,510,565,833,000 |
As far as I can tell from the documentation of systemd, Wants= and WantedBy= perform the same function, except that the former is put in the dependent unit file and vice-versa. (That, and WantedBy= creates the unit.type.wants directory and populates it with symlinks.)
From DigitalOcean: Understanding Systemd Units ... |
Functionally
Wants is in the Unit section and WantedBy is in the Install.
The init process systemd does not process/use the Install section at all. Instead, a symlink must be created in multi-user.target.wants. Usually, that's done by the utility systemctl which does read the Install section.
In summary, WantedBy is a... | Best practice for Wants= vs WantedBy= in Systemd Unit Files |
1,510,565,833,000 |
In this example of a systemd unit file:
# systemd-timesyncd.service
...
Before=time-sync.target sysinit.target shutdown.target
Conflicts=shutdown.target
Wants=time-sync.target
systemd-timesyncd.service should start before time-sync.target.
This defines an ordering dependency.
But at the same systemd-timesyncd.servic... |
The use case of this double relation is similar to a “provides” relation. systemd-timesyncd provides a time synchronisation service, so it satisfies any dependency a unit has on time-sync.target. It must start before time-sync.target because it’s necessary for any service which relies on time synchronisation, and it w... | "before" and "want" for the same systemd service? |
1,510,565,833,000 |
OS: Ubuntu 20.04.3
$ \cat /home/nikhil/.config/systemd/user/Festival.service
[Unit]
Description=Festival Service
[Service]
ExecStart=/usr/bin/festival --server
Restart=on-failure
RestartSec=10
SyslogIdentifier=FestivalService
[Install]
WantedBy=multi-user.target
Description
I did systemctl --user enable Festival.se... |
multi-user.target is appropriate for the system-bus, but you are using --user which works with the user-bus. The user-bus does not typically have multi-user.target
stew ~ $ sudo systemctl status multi-user.target
● multi-user.target - Multi-User System
Loaded: loaded (/lib/systemd/system/multi-user.target; stati... | Systemd service does not start (WantedBy=multi-user.target) |
1,510,565,833,000 |
I'm attempting to make a systemd service that should only start if a certain file doesn't exist on the file system.
If I use ConditionPathExists this will make the service start only when the file in question exists, which is the opposite behavior of what I want.
Is there a way to invert these conditions?
|
Yes, use ! to negate the condition:
[Unit]
ConditionPathExists=!/some/path/to/some/file
It's in the manual:
With ConditionPathExists= a file existence condition is checked before
a unit is started. If the specified absolute path name does not exist,
the condition will fail. If the absolute path name passed to
... | Systemd - Invert Conditions in unit file? |
1,510,565,833,000 |
This $(ls -d...) does not work in a systemd unit file:
[Service]
Type=forking
Environment="ORACLE_HOME=$(ls -d /usr/lib/oracle/*/client64 | sort -rV | head -n1)"
Environment="TNS_ADMIN=$(ls -d /usr/lib/oracle/*/client64/lib/network/admin | sort -rV | head -n1)"
I want to avoid hard-coding the Oracle client version (a... |
Most common methods:
Use an EnvironmentFile= that is generated on the fly, e.g. via ExecStartPre= that calls a simple script. Current systemd versions will re-read EnvironmentFile before each exec to allow this to work. (/run is a good location for the temporary file.)
This is the simplest method, as the script only ... | How to specify dynamic "Environment" variables in a systemd unit file? |
1,510,565,833,000 |
Given the CLI tool systemctl edit can be used to edit existing systemd units such as services, timers, sockets, devices, mounts, automounts, targets, swap, path, slice, scope or nspawn files and you have another subcommand that can delete/reset systemd units can I also create a new systemctl file like this?
Most guide... |
Actually, if you try to run the systemctl edit command with a new, not-yet-existing service, it will tell you exactly what to do:
$ systemctl edit happy-unicorns.service
No files found for happy-unicorns.service.
Run ‘systemctl edit --force --full happy-unicorns.service' to create a new unit.
As such to create a new ... | Create a new systemd unit/service/timer/sockets with systemctl from the command line? |
1,510,565,833,000 |
I've been reading up on systemd and doing a little probing regarding device unit-files.
According to the man pages:
systemd will dynamically create device units for all kernel devices that are marked with the "systemd" udev tag (by default all block and network devices, and a few others). This may be used to define d... |
The answer is in the first sentence you quoted. "systemd will dynamically create device units". It says "create", not just "start". Through integration with the udev daemon, once the kernel tells udev about a new device, a .device unit will be synthesized on the fly. (And similarly, if a device disappears, the .device... | Why are there no device unit files in Debian? |
1,510,565,833,000 |
I'm having trouble using gpg (actually, the gpg-agent) on my Debian Bullseye (Stable) system. More precisely, I use the following:
gpg --version | head -n2
gpg (GnuPG) 2.2.27
libgcrypt 1.8.8
uname -v
#1 SMP Debian 5.10.46-4 (2021-08-03)
lsb_release -a 2> /dev/null
Distributor ID: Debian
Description: Debian GNU/L... |
I finally found a solution, although I'm not sure I understand it.
Somehow the version of gpg-agent started by systemd was the issue. When performing systemctl --user mask gpg-agent and then restarting the gpg-agent manually, the problem disappeared. I'll try to understand why that was the case and then write an upd... | gpg-agent hanging when trying to access private keys |
1,510,565,833,000 |
When I reboot my Raspberry Pi (Stretch) a daemon fails to start because /run/user/1000 does not exist. This is my unit file:
[Unit]
Description=SBFspot Upload Daemon
[Service]
User=pi
Type=forking
TimeoutStopSec=60
ExecStart=/usr/local/bin/sbfspot.3/SBFspotUploadDaemon -p /run/user/1000/sbfspotupload.pid 2>&1> /dev/n... |
/run/user/1000, which of course does not exist until user #1000 logs in or explicitly starts up xyr per-user service management, is a red herring. The entire mechanism that uses it should not be there.
Bug #215 for this program runs a lot deeper than you think. This service unit file is very wrong, as is the operati... | /run/user/$UID not mounted when daemon starts |
1,510,565,833,000 |
On my arch server, I was setting up users restricted to their home directories. I ran:
useradd -m -s /bin/bash username and passwd username
I've read this wiki article...
I figured I should use systemd user services to make each user run a node server on startup. So i logged into one user account su username and creat... |
So I logged into one user account su username
No, you did not.
You are not logging in. You are augmenting the privileges of your existing login session with su username.
systemctl with the --user option locates your per-user Desktop Bus, managed by you per-user Desktop Bus dæmon, and via that bus communicates wit... | How do I setup user autostart and properly configure systemd user services? |
1,510,565,833,000 |
I try use date output as part of log file name in systemd unit.
Here example:
[Unit]
Description=TCS minetest server unit
[Service]
Type=simple
ExecStart=/home/tcs/minetest/bin/minetestserver --worldname world --logfile /home/tcs/logs/debug_$$(date +%%Y_%%m_%%d).txt
ExecReload=/bin/kill -HUP $MAINPID
User=tcs
[Insta... |
This type of syntax is not directly supported, as explained on the man page for system.service:
This syntax is inspired by shell syntax, but only the meta-characters
and expansions described in the following paragraphs are understood,
and the expansion of variables is different. Specifically, redirection
using ... | Use dynamic date in systemd unit |
1,510,565,833,000 |
I understand that systemd stores unit files at different locations for different versions of Linux. On RHEL, it's at /usr/lib/systemd/system/, whereas on Debian-based machines it's at /lib/systemd/system/.
However, on my Ubuntu 18.04 machine, I just installed Elasticsearch using a .deb file, and its systemd unit file ... |
The paths systemd looks up for unit files is read from UnitPath and can be queried with systemctl.
# systemctl --no-pager --property=UnitPath show | tr ' ' '\n'
UnitPath=/etc/systemd/system.control
/run/systemd/system.control
/run/systemd/transient
/etc/systemd/system
/run/systemd/system
/run/systemd/generator
/lib/s... | Why does a systemd unit file at `/usr/lib/systemd/system/` still works for Ubuntu? |
1,510,565,833,000 |
Description of condition
I ran into a strange condition with systemd and ssh on Ubuntu 18.04.3 LTS
I checked the status of the ssh.socket unit:
$ systemctl status ssh.socket
● ssh.socket - OpenBSD Secure Shell server socket
Loaded: loaded (/lib/systemd/system/ssh.socket; disabled; vendor preset: enabled)
Active:... |
A systemd socket is a special type of unit that causes systemd to itself bind to the port (or other resource, such as a unix domain socket file path) and spawn a new instance of a service for any connection. With ssh.service enabled, its sshd that runs continuously and binds to the socket, as your lsof shows. Having s... | Why ssh.socket is set to conflict with ssh.service (Ubuntu 18.04.3)? |
1,510,565,833,000 |
When we issue "systemctl status", we usually get in the output, a line showing the status and for how long it has been in that status.
Like: (I issued that few minutes ago)
Active: active (running) since Wed 2023-11-22 01:56:06 CST; 10h ago
However, it happened to get the following line for the same service when the ... |
You probably have hit this Systemd bug which occurs when your RTC is set to the local time (timedatectl will confirm this).
Either upgrade Systemd or set your RTC to UTC:
# timedatectl set-local-rtc 0
The latter is preferable. Quoting the timedatectl manual:
Note that maintaining the RTC
in the local timezone is not... | Why systemctl status shows a time in the future and the amount of time left? |
1,510,565,833,000 |
I have added my service to systemd (I am running it on a pi3), it looks like this:
[Unit]
Description=Oral-B BLE scanner service
Wants=network-online.target
After=network-online.target
StartLimitBurst=10
StartLimitIntervalSec=10
Requires=bluetooth.target
[Service]
Type=simple
WorkingDirectory=/home/pi/scripts
ExecSta... |
It's not being started because it's not wanted by anything that gets started.
[Install]
WantedBy=network-online.target
I have added a symbolic link to the above file in /lib/systemd/system.
Pretty much all of that is wrong.
The unit file should be placed in /etc/systemd/system. Symbolic links are interpreted idiosyn... | systemd service ends up in “inactive (dead)” after boot |
1,510,565,833,000 |
Arch 5.18/ MATE Desktop
I have a user service that sets up values for my panel
[Unit]
Description=Set values for panel widgets
After=mnt-ram
After=sys-subsystem-net-devices-eno1.device
[Service]
ExecStart=/home/stephen/bin/panel-setup.sh
Type=oneshot
RemainAfterExit=True
[Install]
WantedBy=default.target
Both mnt-... |
The error is in After=mnt-ram
The actual value given by systemctl --user list-units is mnt-ram.mount NOT mnt-ram.
In accessing systemd units I've fallen into the habit of omitting the .service extension (eg. systemctl restart servicename) so dropped the extension here where referencing the mnt-ram.mount service.
| systemd user unit error on boot : Failed to add dependency ignoring: Invalid argument |
1,510,565,833,000 |
man systemd.exec says concerning ExecSearchPath=:
Takes a colon separated list of absolute paths relative to which the executable used by the Exec*= (e.g. ExecStart=, ExecStop=, etc.) properties can be found. ExecSearchPath= overrides $PATH if $PATH is not supplied by the user through Environment=, EnvironmentFile= o... |
The default binary search path is described in the section on command lines:
If the command is not a full (absolute) path, it will be resolved to a full path using a fixed search path determined at compilation time. Searched directories include /usr/local/bin/, /usr/bin/, /bin/ on systems using split /usr/bin/ and /b... | What is the default value of `ExecSearchPath=` in a systemd unit file? |
1,510,565,833,000 |
I'm trying to make a systemd service have a conditional start based on multiple hostname pattern.
I've tried this without luck:
root@linkbox-BI034415:/# systemctl cat mcbapp
# /lib/systemd/system/myservice.service
[Unit]
Description=My Service
Wants=another.service
After=another.service
ConditionHost=HostOne*|HostTwo*... |
tl;dr:
ConditionHost=|HostOne*
ConditionHost=|HostTwo*
You can easily check your conditions with systemd-analyze. That should speed up your testing.
Here's an example where I am using ConditionHost on my own machine (stewbian).
Here, I succeed with an exact match.
$ systemd-analyze condition ConditionHost=stewbian
t... | How to check multiple host name in systemd unit condition |
1,510,565,833,000 |
I’m using Debian 11 on a Raspberry Pi 4 (image found here).
sshd is properly configured (I only edited /etc/ssh/sshd_config, the rest is completely fresh from system installation) and works correctly when I start it manually. However it doesn’t start automatically by systemd at boot. sudo systemctl status sshd returns... |
Could this be the same issue as the one the asker of question #442181 had? I.e. sshd fails to start at boot because the interface/address it wants to bind to isn't ready yet. You mention that you've specified a non-standard port for the server socket, have you also specified a particular network interface and/or IP ad... | Why ssh.service doesn’t start automatically during boot despite being enabled by systemd? |
1,510,565,833,000 |
I'm using systemd version 246:
$ systemctl --version
systemd 246 (246.2-1-arch)
+PAM +AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
which documents ConditionE... |
I don't think you are doing anything wrong. I think there's a bug in systemd.
On Debian testing (systemd 246, and later on 246.1 after upgrading) I observed the following:
ConditionEnvironment= was only released with version 246 on July 30 2020 (2.5 weeks before time of writing) and the pull request was merged on May... | systemd: Unknown key name 'ConditionEnvironment' in section 'Unit' |
1,510,565,833,000 |
I have created a SystemD unit to start a service, and that service requires another unit to start beforehand.
I've set the depending service with Requires=dependant.service, and that way when depending.service is automatically started during boot, it first tries to start dependant.service.
The problem is that if depe... |
It seems that the root cause is that dependant.service is starting too soon sometimes: adding Restart directives is a bit of a hack. This to me indicates that it's missing a timing requirement, which is what After is for. Depending on the type of service, you'll need to determine what resources are needed before the s... | SystemD `Requires` fail when required unit fails for the first time |
1,510,565,833,000 |
I'm debugging a firewall .service unit and a few questions arise.
One of those questions is the unit's best service type, either exec or oneshot. Virtually no comparisons of the two appear in my searches, probably because exec is a relatively recent addition to systemd (v.249 IIRC).
By way of background, the unit (ca... |
You want type=oneshot. If you use type=exec, other services will be able to start before the firewall is configured. From the systemd.service man page, for exec:
...Or in other words: simple proceeds with further jobs right after fork() returns, while exec will not proceed before both fork() and execve() in the servi... | systemd Firewall .service Unit: Type=exec or Type=oneshot? |
1,522,633,198,000 |
I'm trying to implement the delayed hibernation unit. I'm on arch/antergos.
>>> systemctl enable suspend-to-hibernate.service
Failed to enable unit ...to-hibernate.service: Invalid argument
systemd-analyze verify ...hibernate.service responds with an empty output.
I copied the unit file straight from the arch wiki an... |
As given in the Arch wiki page, the file should be in /etc/systemd/system/. There are several directories where systemd looks for unit files, and /etc/systemd/system/ is where a system administrator should place their service files. See man systemd.unit.
After creating or a modifying a file in these directories, you h... | systemd invalid argument - debugging delayed hibernation service file |
1,522,633,198,000 |
I'm using a systemd unit file in order to control a python process running on a server (with systemd v247).
This process must be restarted 60 seconds after it exits, either on failure or on success, except if it fails 5 times in 600 seconds.
This unit file links another service in order to notify failures by email.
/e... |
There are several things you should do in order to work with the system service as you want (changes are on /etc/systemd/system/python-test.service).
Change Restart=always to Restart=on-failure
The values StartLimitInterval=600, StartLimitBurst=5 seem to be supported yet. However you should place them in [Unit]. If y... | Service OnFailure trigerred only after burst limit reached |
1,522,633,198,000 |
I have created a target file /etc/systemd/system/watch-for-sync-need-all.target
[Unit]
Description=systemd target to group services for all folders that create a sync need by changes
After=multi-user.target
Wants=watch-for-sync-need@_sl_home_sl_.service
Wants=watch-for-sync-need@_sl_stream_sl_.service
[Install]
Also=... |
In the Install-section of /etc/systemd/system/watch-for-sync-need-all.target multi-user.target had to be added as WantedBy and now it works.
In this stack overflow thread Systemd with multiple execStart
comment 5 by Johny mentions that.
I do not understand, why this is needed, since the target is supposed to start aft... | systemd start stop enable and disable multiple services with one target unit |
1,522,633,198,000 |
Newbie systemd user here; my apologies if the question seems 'too basic' and would be better asked elsewhere on the StackOverflow ecosystem...
I'm in the process of converting some of my ancient init service files, written 12 years ago or so, to systemd. Some of those had rather nasty tricks to figure out how to confi... |
If PartOf is part of the service [Unit] then the target shouldn't need Wants; systemd will automatically know what templates have been enabled for the target.
systemctl enable myapp@Chicago (etc) should work with what's in the descrption.
Remove Wants= from the target and systemctl enable myapp and then systemctl star... | How to dynamically create a list of units for a `systemd` target? |
1,522,633,198,000 |
I can't wrap my head around systemd unit files.
Here's my scenario, I have a service called: my.service
my.service needs to start sometime after boot, whenever everything else is ready, no rush.
my.service starts a docker container so I want to start the docker.service before starting my.service (it is possible that d... |
Check out the systemd.unit man page to see descriptions, I've included them below, but will do my best to explain.
Requires is a strong dependency. If my.service gets activated then anything listed after Requires= also gets activated. If one of the units listed after Requires= is explicitly stopped, then my.service al... | systemd nightmare - ordering my service so it starts at boot and restarts when needed |
1,522,633,198,000 |
I have the following problem:
I have my network drive in my home network that I would like to mount via sshfs. Being in my local network I don't have to care that much about encryption and could use the arcfour cipher for example. My ssh port internally is A.
For technical reasons I can connect from the outside networ... |
I'd suggest, you run two actions: one upon login (for mounting), the other one upon logout (unmounting). A sample service file:
[Unit]
Description=mount with sshfs
[Service]
Type=simple
ExecStart=/path/to/login_script.sh
#This makes the service stay active while logged in and
# makes sure ExecStop is only execut... | Define systemd service conditional to network ID |
1,522,633,198,000 |
OS: Debian 11 Bullseye
Context:
The Zerotier application adds the zerotier-one.service system service and creates a virtual network interface (when it works).
The sshd server default listens to all addresses 0.0.0.0
Until then, everything is fine with me
Now I am introducing custom config in /etc/ssh/sshd_config.d/m... |
With your configuration, sshd.service will certainly start only after zerotier-one.service starts. But that is not enough. The sshd.service would need to wait until Zerotier has actually connected successfully, which can happen quite a bit later (in computer timescales, at least). And the current zerotier-one.service ... | Reorder of launching Systemd services |
1,522,633,198,000 |
I'm struggling to make a SpringBootApp to run as a service at the moment. The biggest issue is that Devops doesn't allow us to make changes on the Ansible scripts that deploys the artifact and creates the service (sample shown below).
[Unit]
Description=A Spring Boot application
After=syslog.target
[Service]
User=rat... |
You could use the Linux kernel support for miscellaneous binary formats (binfmt_misc). This allows you to register an interpreter (e.g. Java) to execute a file based on the first few bytes in the file (e.g. a jar file). See
https://www.kernel.org/doc/Documentation/admin-guide/binfmt-misc.rst for more information.
| Java systemd service without specifying java -jar |
1,522,633,198,000 |
I have a service that processes items from a RabbitMQ queue, of which I spool additional instances as the queue grows in size. How can I enable systemd to start a single instance of the unit at startup?
Here's my unit file:
[Unit]
Description=A service (%i) to consume items from a queue
After=network.target
[Service]... |
systemctl enable <servicename>@<instancename>
| How to enable systemd unit to run at startup |
1,522,633,198,000 |
For systemd's system units (the units you operate with systemctl --system (default)), it's possible to specify DynamicUser=yes to make systemd dynamically allocate a user and group for the service to achieve some sense of sandboxing.
However while reading the manual I was not able to find any mention of if and how it ... |
I would agree with @Iarsks's comment in that DynamicUser=yes doesn't make much sense for a user unit.
Obviously, you wouldn't be able to create and switch users. And if your unit needs to be a user-unit, then you wouldn't want this anyways.
So why do you want to add DynamicUser= to a --user unit? An obvious answer c... | systemd - does the `DynamicUser` option work with user units and if so, how? |
1,522,633,198,000 |
I have a inotify-based service that backs up my LAN's git directory to the Dropbox. I tried keeping the git directory in the Dropbox but I have multiple git clients so often get error files there.
In this early stage of development, this is a fairly busy and chatty system service that wants to log to a ram drive. I d... |
On Arch, at least, systemd mounts generated from /etc/fstab are deployed to /run/systemd/generator
For example on my system, with the listing below I can add to my service file
[Unit]
Description=backup logging to temp
After=mnt-ram.mount
ls -la /run/systemd/generator
:> ls -la
total 32
-rw-r--r-- 1 root root 362 J... | systemd service to start after mount of ram drive |
1,522,633,198,000 |
It is necessary to create a virtual file samba.img that will be a device and automatically mount it when the system starts.
creating a virtual disk from a file
fallocate -l 2G /root/img/samba.img
mkfs.ext4 /root/img/samba.img
craating mount point
sudo mkdir /srv/smb
I create a mount file to run at system start... |
well, the error tells you what's wrong!
Read man systemd.mount to learn about the unit file name requirements:
Mount units must be named after the mount point directories they control. Example: the mount point /home/lennart must be configured in a unit file home-lennart.mount. For details about the escaping logic use... | Systemd mount unit configuration *.img file on centos |
1,522,633,198,000 |
OS - Red Hat Enterprise Linux 8
I've created a .spec file to build and package my application. My rpm also includes my_app.service file for systemd to start it. However, by default one has to enable this with systemctl enable my_app.service. I'd like to have it enabled after the rpm has been installed. I've googled an... |
Does it mean I should not be adding .preset file in my rpm?
Yes, you shouldn't put the .preset file in your service's package RPM
but it is not happening
It's not happening because the systemd package in RHEL ships with a default preset at /usr/lib/systemd/system-preset/90-systemd.preset.
If you want to stick to d... | automatically activate service after RPM was installed |
1,522,633,198,000 |
I've created a unit file to mount the /srv partition automatically. It will check first if /dev/mapper/srv exists and then start it. I'd like to take it one step further and only let it be able to start if /dev/mapper/srv is a LUKS encrypted block device, with the ConditionPathIsEncrypted option. But I get the warning... |
ConditionPathIsEncrypted= only exists in versions v264-rc1 and newer.
If you want to look what conditions the version you are using supports, i would suggest you take a look at the 'systemd.unit' manpage.
man systemd.unit
There is a section with 'Conditions and Asserts' - the systemd version shipping with Ubuntu 20.0... | ConditionPathIsEncrypted not supported? |
1,522,633,198,000 |
According to various clauses in the docs, the "activating" state is the transition between inactive states and an active state. So far so obvious.
But how exactly is it defined?
What determines whether a service is no longer inactive but activating?
What determines whether a service is no longer activating but active?... |
while it is running, the service remains "activating".
That would indicate you're using the wrong Type= for your service file. See man systemd.unit and systemd.service for a pretty detailed discussion on when what service is called started. The text is too long to reasonably copy & paste in here, but from the Type= ... | What exactly does it mean for a systemd service to be "activating"? |
1,522,633,198,000 |
I have a Golang binary that runs every 5 mins. It is supposed to create & update a text file which needs to be write restricted. To run this binary I created a systemd service and a systemd timer unit. Systemd service uses a DynamicUser. To achieve access restriction i use CacheDirectory directive in systemd so that o... |
CacheDirectoryMode=644
This allows to read the directory list. Not to interact with a file within this directory list: the eXecute bit is required to further traverse the path and access files within the directory. This makes the write access for user monitor also useless.
Change this parameter into:
CacheDirectory... | Systemd executable failed to read file from CacheDirectory with Permission Denied |
1,522,633,198,000 |
I have systemd:
service1.service
service2.service
service3.service
service1.service looks like:
[Unit]
Wants=service2.service service3.service
After=service2.service service3.service
[Service]
ExecStart=/var/scripts/script.sh
[Install]
WantedBy=multi-user.target
This service1.service does what it should - it brin... |
Looking at the documentation, there appear to be several options available.
The simplest may be the PropagatesStopTo= option:
PropagatesStopTo=, StopPropagatedFrom=
A space-separated list of one or more units to which stop requests from this unit shall be propagated to, or units from which stop requests shall be prop... | Bring systemd services up/down along with specific systemd service? |
1,522,633,198,000 |
I'm wrapping a 3rd party executable in a systemd service unit to manage it. I can't alter the behavior of this program and I don't really trust its exit codes. I would like to treat any exit that was not caused by systemd as a failure, that includes exit code 0 or an outside SIGTERM, so I can detect the difference t... |
I may not have understood what you need, but perhaps you can do something simple like adding a failing command after the foo command. This second command would not be run by systemctl stop. For example, replace the ExecStart with
ExecStart=/bin/bash -c '/opt/foo/foo -stayresident && exit 7'
The choice of 7 is just so... | Make systemd treat unexpected exit as failure |
1,522,633,198,000 |
I get this message from systemd status after I have stopped my service:
Actice: failed (Result: exit-code) <...> Main PID: 4747 (code=exited, status=202/FDS)
Status FDS is defined in the docs like this:
202 EXIT_FDS Failed to close unwanted file descriptors, or to adjust passed file descriptors.
Starting the servic... |
Since the service has Type=forking, the ExecStart process had PID 4758 and the exit code you're asking about is listed with main PID 4747, we can conclude that systemd managed to fork() a child process which then successfully execve()'d the ExecStart process, and so the table of systemd-specific exit codes does not ap... | What does systemd exit code EXIT_FDS mean? |
1,522,633,198,000 |
How can I customize systemd source code? When I do bitbake, systemd appears in my end project, but I cannot find any source files of it in my local directories. I want to track down unit files lifecycle, log_debug(...) and log_info(...)s are not showing up (some of the messages appear, but gives not enough info for me... |
Besides adding recipe name to the RM_WORK_EXCLUDE += "systemd" in local.conf, one should clean shared state using one of the cleaning options provided by Yocto, for example $ bitbake -c cleansstate recipe before bitbaking again, otherwise, with an unflushed shared state cache it will start from the current state, not ... | How Yocto embeds systemd in end project? |
1,522,633,198,000 |
So, I started breaking up my system init and creating some service files for things I want to be loaded after I login. It's the usual stuff like polybar, dunst and the rest of the things. Things do work, but I have some issues with my pywal setup. I've separated the dependencies into a separate .target called
theme.ta... |
There is a mismatch between your understanding of "successfully running" and systemd's idea. For services such as these, the "Type" is "simple", which means:
If set to simple (the default if ExecStart= is specified but neither Type= nor BusName= are), the service manager will consider the unit started immediately aft... | After= directive of systemd unit not working as expected |
1,374,433,691,000 |
root@system:~# less myfile
-bash: /bin/less: Input/output error
The root filesystem is dead. But my cat is still alive (in my memory):
root@system:~# cat > /tmp/somefile
C^d
root@system:~#
He's kind of lonely though, all his friends are gone:
root@system:~# mount
-bash: /bin/mount: Input/output error
root@system:~# ... |
There are several possibilities, all depending on the exact parameters of your situation right now. I'm going to assume Linux in the following examples where applicable, but similar functionality exists on other platforms in most cases.
You might be able to get the dynamic loader to run an executable for you. Assumin... | Change permisions of a file with my cat's help |
1,374,433,691,000 |
And now I am unable to chmod it back.. or use any of my other system programs. Luckily this is on a VM I've been toying with, but is there any way to resolve this? The system is Ubuntu Server 12.10.
I have attempted to restart into recovery mode, unfortunately now I am unable to boot into the system at all due to per... |
Boot another clean OS, mount the file system and fix permissions.
As your broken file system lives in a VM, you should have your host system available and working. Mount your broken file system there and fix it.
In case of QEMU/KVM you can for example mount the file system using nbd.
| How to recover from a chmod -R 000 /bin? |
1,374,433,691,000 |
I was reading the famous Unix Recovery Legend, and it occurred to me to wonder:
If I had a BusyBox shell open, and the BusyBox binary were itself deleted, would I still be able to use all the commands included in the BusyBox binary?
Clearly I wouldn't be able to use the BB version of those commands from another runnin... |
By default, BusyBox doesn't do anything special regarding the applets that it has built in (the commands listed with busybox --help).
However, if the FEATURE_SH_STANDALONE and FEATURE_PREFER_APPLETS options are enabled at compile time, then when BusyBox sh¹ executes a command which is a known applet name, it doesn't d... | Are BusyBox commands truly built in? |
1,374,433,691,000 |
As the headline says everything or almost everything important as root under root (/) was moved to /old on a Solaris 10 machine. So now the typical fault when trying when running commands are Cannot find /usr/lib/ld.so.1 (changed $PATH and also tried changing $LD_LIBRARY_PATH, $LD_LIBRARY_PATH_64 and $LD_RUN_PATH and ... |
If you no longer have a shell running as root, you'll have to reboot into rescue media. Anything will do as long as it's capable of mounting the root filesystem read-write.
If you can still run commands as root, everything's copacetic. Set the environment variable LD_LIBRARY_PATH to point to the directories containing... | unix - accidentally moved everything under root to /old - Solaris 10 |
1,374,433,691,000 |
Long story short, I destroyed /var and restored it from backup - but the backup didn't have correct permissions set, and now everything in /var is owned by root. This seems to make a few programs unhappy.
I've since fixed apt failing fopen on /var/cache/man as advised here as well as apache2 failing to start (by givin... |
Actually apt-get --reinstall install package should work, with files at least:
➜ ~ ls -l /usr/share/lintian/checks/version-substvars.desc
-rw-r--r-- 1 root root 2441 Jun 22 14:19 /usr/share/lintian/checks/version-substvars.desc
➜ ~ sudo chmod +x /usr/share/lintian/checks/version-substvars.desc
➜ ~ ls -l ... | Fix broken permissions on /var (or any other system directory) |
1,374,433,691,000 |
Assuming that you can't reach the internet nor reboot the machine, how can I recover from
chmod -x chmod
?
|
1 - use a programming language that implements chmod
Ruby:
ruby -e 'require "fileutils"; FileUtils.chmod 0755, “chmod"'
Python:
python -c "import os;os.chmod('/bin/chmod', 0755)”
Perl:
perl -e 'chmod 0755, “chmod”'
Node.js:
require("fs").chmod("/bin/chmod", 0755);
C:
$ cat - > restore_chmod.c
#include <sys/types.... | How can I recover from a `chmod -x chmod`? [duplicate] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.