Systemd question. Why?

Please help me!

I create “recordmic.service” file and make service:

[Unit] Description=Recording Microphone  [Service] PIDFile=/home/sergey/arec/ WorkingDirectory=/home/sergey/arec/ ExecStart=/home/sergey/arec/recordmic User=sergey Group=sergey Nice=10 SyslogIdentifier=RecMic StandardOutput=syslog Restart=on-failure KillSignal=SIGINT  [Install] 

and create file for run in /home/sergey/arec/arec:

#!/bin/bash cd /home/sergey/arec /usr/bin/arecord -f S16_LE -N -t wav -c1 -r 22050 --max-file-time=60 --use-strftime /home/sergey/arec/files/%Y-%m-%d-%H-%M-%v.wav 

then i run direct “arec” from /home/sergey/arec the wave file was created and correct with my recorded voice


then i run as daemon (sudo systemcts start recordmic.service) the arecord was run but created wave file is empty! null bytes array fill

Why? Help me please!

Custom sh script not called from systemd service in Ubuntu 18.04

I’m trying to create/run a service, i.e start a script on boot using systemd.

First, when I test my script with $ /usr/bin/, it works well.

So, I tried to create my service:

$   sudo nano /etc/systemd/system/pastec.service 

It looks like:

[Unit] Description=Pastec Service  [Service] ExecStart=/usr/bin/ Restart=always RestartSec=5  [Install] 

Then, to launch it:

systemctl daemon-reload systemctl enable pastec.service systemctl start pastec 

The code is executed, no error is returned.

root# systemctl start pastec root#  

But the service/task doesn’t exist when I run ps aux | grep pastec

NOTE: I was running this script at startup using init.d on Ubuntu 14.04 – Now I want to run it on Ubuntu 18.04 using systemd.

What did I miss ?

EDIT 1: as queried by PonJar, this is what I can see with systemctl status pastec

● pastec.service - Pastec Service    Loaded: loaded (/etc/systemd/system/pastec.service; enabled; vendor preset: enabled)    Active: activating (auto-restart) since Wed 2019-10-02 06:01:07 UTC; 4s ago   Process: 8339 ExecStart=/usr/bin/ (code=exited, status=0/SUCCESS)  Main PID: 8339 (code=exited, status=0/SUCCESS) 

But no trace of pastec with grep…

systemd ignores docker configuration file at /etc/docker/daemon.json

Docker service will not use /etc/docker/daemon.json configuration during startup.

user@host:~$   cat  /etc/docker/daemon.json {   "exec-opts": ["native.cgroupdriver=systemd"],   "log-driver": "json-file",   "log-opts": {     "max-size": "100m"   },   "storage-driver": "overlay2" } 

I have to use systemctl daemon-reload and systemctl restart docker after every reboot, then the docker service will use daemon.json file to override default settings.

Is there a way to make this persistent ?

Removing an item from systemd startup

My boot time is very high and when I use

systemd-analyze blame  

I get the following result

     25.282s home-arianhf-google\x2ddrive.mount      23.567s systemd-journal-flush.service      23.232s dev-sda9.device 

and the result of systemctl list-units --type=mount is :

UNIT                                    LOAD   ACTIVE SUB     DESCRIPTION                                       -.mount                                 loaded active mounted Root Mount                                        dev-hugepages.mount                     loaded active mounted Huge Pages File System                            dev-mqueue.mount                        loaded active mounted POSIX Message Queue File System                 ● home-arianhf-google\x2ddrive.mount      loaded failed failed  /home/arianhf/google-drive                        mnt-ubuntu.mount                        loaded active mounted /mnt/ubuntu                                       proc-sys-fs-binfmt_misc.mount           loaded active mounted Arbitrary Executable File Formats File System   

notice the failed mount.

i want to remove this from my systemd. How can I do this?

Do world-writable systemd .service files created as symbolic links in /etc/systemd/system impose a security threat?

Do world-writable systemd .service files created as symbolic links in /etc/systemd/system impose a security threat?

Would it be possible to somehow modify the links to target arbitrary .service files on the system, and make systemd execute those files as root?

The permissions for the /etc/systemd/system directory is as follows:

drwxr-xr-x. 11 root root 4096 Aug 30 12:57 /etc/systemd/system/ 

and the world-writable links in this directory are:

1050594    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:53 /etc/systemd/system/ -> /dev/null 1050595    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:54 /etc/systemd/system/sensu-server.service -> /dev/null 1052003    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:54 /etc/systemd/system/sensu-api.service -> /dev/null 1052037    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:55 /etc/systemd/system/dataeng.service -> /dev/null 

Ubuntu 19.04 systemd runs script on USB Drive insertion, but fails to start gnome-terminal

first post here…

Looking for some assistance please

I have a systemd process that runs on usb drive insertion, however, I need the terminal to open with this systemd command and it is continually failing to start. By the looks of the systemctl status log when I run “sudo systemctl status elements-usb.service” it would appear the environmentals are wrong or the syntax of my command.

monster@monster-laptop:~$ sudo systemctl status elements-usb.service

Warning: The unit file, source configuration file or drop-ins of elements-usb.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.

● elements-usb.service – elements-usb-trigger Loaded: loaded (/etc/systemd/system/elements-usb.service; enabled; vendor preset: enabled)

Active: failed (Result: exit-code) since Fri 2019-08-23 15:05:30 BST; 4s ago

Process: 26361 ExecStart=/usr/bin/dbus-launch gnome-terminal –command=bash -c ‘/home/monster/.storage-scripts/elements-run-on-mount; $ SHELL’ (code=exited, status=1/FAILURE) Main PID: 26361 (code=exited, status=1/FAILURE)

Aug 23 15:05:30 monster-laptop systemd[1]: Started elements-usb-trigger.

Aug 23 15:05:30 monster-laptop dbus-daemon[26382]: [session uid=0 pid=26371] AppArmor D-Bus mediation is enabled

Aug 23 15:05:30 monster-laptop dbus-launch[26361]: # Option “–command” is deprecated and might be removed in a later version of gnome-terminal.

Aug 23 15:05:30 monster-laptop dbus-launch[26361]: # Use “– ” to terminate the options and put the command line to execute after it.

Aug 23 15:05:30 monster-laptop dbus-launch[26361]: Unable to init server: Could not connect: Connection refused

Aug 23 15:05:30 monster-laptop dbus-launch[26361]: # Failed to parse arguments: Cannot open display:

Aug 23 15:05:30 monster-laptop systemd[1]: elements-usb.service: Main process exited, code=exited, status=1/FAILURE

Aug 23 15:05:30 monster-laptop systemd[1]: elements-usb.service: Failed with result ‘exit-code’.

the systemd command runs the following:

[Unit] Description=elements-usb-trigger Requires=home-usb\x2dstorage.mount After=home-usb\x2dstorage.mount

[Service] ExecStart=dbus-launch gnome-terminal –command=”bash -c ‘/home/monster/.storage-scripts/elements-run-on-mount; $ SHELL'”

[Install] WantedBy=home-usb\x2dstorage.mount

Any clues plse? I’m at a loss now

Systemd long boot

Good day. I have a Dell Latitude 6440 -intel i5-4310 laptop, 8GB RAM disk – SSD. System on SD card – Ubuntu Mate 18.04.3 kernel 5.2.8. with encrypted partition / home. This is what system-analyze looks like: Startup finished in 8.807s (firmware) + 30.926s (loader) + 3.776s (kernel) + 32.108s (userspace) = 1min 15.618s reached after 32.101s in userspace Tell me what is it responsible for and what is the loader + 30,926s ?? How to speed it up? Thank you.

running a python tkinter gui on startup using systemd

i created a GUI on python/tkinter and i need it to run on startup, can this be done using systemd or do i need to turn the script into an executable because so far every attempt at trying to use systemd as resulted in:

(code=exited, status1/failure) 

is this just a problem with how i configured the .service file or can systemctl not be used to do this?