In Ubuntu 22.04
I have two service units that I have written.
One is terminated without problem by the ExecStop=/bin/kill -1 $MAINPID in the service file.
However, the other does not terminate normally in the same way as above.
$ sudo systemctl stop foo
$ systemctl status foo
× foo.service - foo server
Loaded: loaded (/etc/systemd/system/foo.service; disabled; vendor preset: enabled)
Active: failed (Result: timeout) since Thu 2023-02-16 19:28:31 KST; 2min 24s ago
Process: 141572 ExecStart=/opt/foo/sbin/foo_daemon/foo.py (code=killed, signal=HUP)
Process: 142097 ExecStop=/bin/kill -1 $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 141572 (code=killed, signal=HUP)
CPU: 685ms
Feb 16 19:28:31 esm-op systemd[1]: foo.service: Failed with result 'timeout'.
Feb 16 19:28:31 esm-op systemd[1]: foo.service: Unit process 141605 (foo.py) remains running after unit stopped.
Feb 16 19:28:31 esm-op systemd[1]: foo.service: Unit process 141606 (foo.py) remains running after unit stopped.
Feb 16 19:28:31 esm-op systemd[1]: foo.service: Unit process 141607 (foo.py) remains running after unit stopped.
Feb 16 19:28:31 esm-op systemd[1]: foo.service: Unit process 141608 (foo.py) remains running after unit stopped.
Feb 16 19:28:31 esm-op systemd[1]: foo.service: Unit process 141609 (foo.py) remains running after unit stopped.
Below is my foo.service file.
[Unit]
Description=foo server
StartLimitIntervalSec=60
StartLimitBurst=3
[Service]
Environment="LD_LIBRARY_PATH=/opt/foo/lib"
ExecStart=/opt/foo/sbin/foo_daemon/foo.py
RestartSec=10
SuccessExitStatus=1 143 11
ExecStop=/bin/kill -1 $MAINPID
[Install]
WantedBy=graphical.target
Can someone help me?
Related
I need to deploy my Go app to aws (ec2 instance), with Ubuntu 18.04, however I can't manage to make it run using the systemd. Here is my created service (/lib/systemd/system/go.service)
[Unit]
Description=go api
[Service]
Type=simple
Restart=always
RestartSec=5s
ExecStart=/home/ubuntu/go/amutan
[Install]
WantedBy=multi-user.target
Here is the result when I run sudo service go start, sudo service go status
go.service - go api
Loaded: loaded (/lib/systemd/system/go.service; disabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Tue 2020-02-25 05
Process: 7326 ExecStart=/home/ubuntu/go/amutan (code=exited, status=203/EXEC)
Main PID: 7326 (code=exited, status=203/EXEC)
Feb 25 05:22:46 ip-172-31-27-28 systemd[1]: Stopped go api.
Feb 25 05:22:46 ip-172-31-27-28 systemd[1]: Started go api.
Feb 25 05:22:46 ip-172-31-27-28 systemd[1]: go.service: Main process exited, code=exited, status=203/EXEC
Feb 25 05:22:46 ip-172-31-27-28 systemd[1]: go.service: Failed with result 'exit-code'.
My go binary resides in /home/ubuntu/go which is named amutan.
Any ideas?
That error message is in the official documentation as
203 EXIT_EXEC The actual process execution failed (specifically, the
execve(2) system call). Most likely this is caused by a missing or
non-accessible executable file.
So check permissions, the exact path and things like selinux settings
I use Linux Mint 19. I have created a simple script, "After_suspension", which will run three commands. I am trying to make it run when Mint wakes up from suspension.
matthew#matthew-pc:~$ cat /usr/local/bin/After_suspension
#!/bin/bash
pon dsl-provider
sudo service fancontrol start
/usr/bin/mailnag
matthew#matthew-pc:~$ file /usr/local/bin/After_suspension
/usr/local/bin/After_suspension: Bourne-Again shell script, ASCII text executable
"mailnag" is (text/x-python). I have created the following service file, which has been enabled but failed. How can I make it run? Should I use three separate service files to run the three commands?
matthew#matthew-pc:~$ cat /etc/systemd/system/After_suspension.service
[Unit]
After=suspend.target
[Service]
ExecStart=/usr/local/bin/After_suspension
[Install]
WantedBy=suspend.target
matthew#matthew-pc:~$ systemctl is-enabled After_suspension.service
enabled
matthew#matthew-pc:~$ systemctl is-active After_suspension.service
failed
matthew#matthew-pc:~$ systemctl status After_suspension.service
● After_suspension.service
Loaded: loaded (/etc/systemd/system/After_suspension.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-04-11 01:19:42 HKT; 3min 46s ago
Process: 11655 ExecStart=/usr/local/bin/After_suspension (code=exited, status=1/FAILURE)
Main PID: 11655 (code=exited, status=1/FAILURE)
Apr 11 01:19:11 matthew-pc After_suspension[11655]: File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in __new__
Apr 11 01:19:11 matthew-pc After_suspension[11655]: bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
Apr 11 01:19:11 matthew-pc After_suspension[11655]: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbu
Apr 11 01:19:07 matthew-pc systemd[1]: Started
After_suspension.service.
Apr 11 01:19:07 matthew-pc systemd[1]: After_suspension.service: Main process exited, code=exited, status=1/FAILURE
Apr 11 01:19:42 matthew-pc pppd[11657]: Timeout waiting for PADO packets
Apr 11 01:19:42 matthew-pc pppd[11657]: Unable to complete PPPoE Discovery
Apr 11 01:19:42 matthew-pc pppd[11657]: Terminating on signal 15
Apr 11 01:19:42 matthew-pc pppd[11657]: Exit.
Apr 11 01:19:42 matthew-pc systemd[1]: After_suspension.service: Failed with result 'exit-code'.
The following is the present "fancontrol.service".
matthew#matthew-pc:~$ cat /lib/systemd/system/fancontrol.service
[Unit]
Description=fan speed regulator
# Run pwmconfig to create this file.
ConditionPathExists=/etc/fancontrol
After=lm-sensors.service
Documentation=man:fancontrol(8) man:pwmconfig(8)
[Service]
ExecStartPre=/usr/sbin/fancontrol --check
ExecStart=/usr/sbin/fancontrol
PIDFile=/var/run/fancontrol.pid
[Install]
WantedBy=multi-user.target
Systemd runs system scripts as root, so you're trying to start GNOME disks as a root, in a terminal session with no X server active, that's why you probably get a connection refused message.
You probably want to configure that service to be an user service (you'll probably have to pass the DISPLAY variable, too), or just first try setting a DISPLAY variable in either your script or systemd service.
Running /opt/gobblin/bin/gobblin-standalone.sh start directly everything works, the output in logs are fine.
Running it through a systemd service, not works. Nothing are outputting in logs.
[vagrant#localhost ~]$ sudo systemctl start gobblin
[vagrant#localhost ~]$ sudo systemctl status gobblin
● gobblin.service - Gobblin Data Ingestion Framework
Loaded: loaded (/usr/lib/systemd/system/gobblin.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Sun 2019-01-20 16:44:23 UTC; 693ms ago
Docs: https://gobblin.readthedocs.io
Process: 9673 ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop (code=exited, status=1/FAILURE)
Process: 9671 ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start (code=exited, status=1/FAILURE)
Main PID: 9671 (code=exited, status=1/FAILURE)
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service: control process exited, code=exited status=1
Jan 20 16:44:23 localhost.localdomain systemd[1]: Unit gobblin.service entered failed state.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service failed.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service holdoff time over, scheduling restart.
Jan 20 16:44:23 localhost.localdomain systemd[1]: Stopped Gobblin Data Ingestion Framework.
Jan 20 16:44:23 localhost.localdomain systemd[1]: start request repeated too quickly for gobblin.service
Jan 20 16:44:23 localhost.localdomain systemd[1]: Failed to start Gobblin Data Ingestion Framework.
Jan 20 16:44:23 localhost.localdomain systemd[1]: Unit gobblin.service entered failed state.
Jan 20 16:44:23 localhost.localdomain systemd[1]: gobblin.service failed.
The code of /usr/lib/systemd/system/gobblin.service below:
[Unit]
Description=Gobblin Data Ingestion Framework
Documentation=https://gobblin.readthedocs.io
After=network.target
[Service]
Type=simple
User=gobblin
Group=gobblin
WorkingDirectory=/opt/gobblin
ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start
ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
The trick is with Type=oneshot, RemainAfterExit=true and set the environments:
[Unit]
Description=Gobblin Data Ingestion Framework
Documentation=https://gobblin.readthedocs.io
After=network.target
[Service]
Type=oneshot
User=gobblin
Group=gobblin
WorkingDirectory=/opt/gobblin
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/jre
Environment=GOBBLIN_FWDIR=/opt/gobblin
Environment=GOBBLIN_JOB_CONFIG_DIR=/etc/gobblin
Environment=GOBBLIN_WORK_DIR=/var/lib/gobblin
Environment=GOBBLIN_LOG_DIR=/var/log/gobblin
ExecStart=/opt/gobblin/bin/gobblin-standalone.sh start
ExecStop=/opt/gobblin/bin/gobblin-standalone.sh stop
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
Hello i have got one problem with icinga. There is a log.
root#fejt-vxp:~# systemctl status icinga2
● icinga2.service - Icinga host/service/network monitoring system
Loaded: loaded (/lib/systemd/system/icinga2.service; enabled)
Drop-In: /etc/systemd/system/icinga2.service.d
└─limits.conf
Active: failed (Result: exit-code) since Mon 2018-08-27 12:06:08 CEST; 37s ago
Process: 4346 ExecStart=/usr/sbin/icinga2 daemon -e ${ICINGA2_ERROR_LOG} (code=exited, status=203/EXEC)
Process: 4338 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/icinga2 (code=exited, status=0/SUCCESS)
Main PID: 4346 (code=exited, status=203/EXEC)
Aug 27 12:06:08 fejt-vxp systemd[1]: Started Icinga host/service/network monitoring system.
Aug 27 12:06:08 fejt-vxp systemd[1]: icinga2.service: main process exited, code=exited, status=203/EXEC
Aug 27 12:06:08 fejt-vxp systemd[1]: Unit icinga2.service entered failed state.
When i wrote systemctl start icinga2 or /etc/init.d/icinga2 start
without action.
thank you
Addition:
Each other applications are ready responding: mysql, apache2
the most useful debugging informations why icinga2 does not start you can find in
/var/log/icinga2/startup.log
or via
journalctl -xe
I am using a Raspberry Pi. To reduce I/O on my SD-Card I symlink all important log files to an external USB-mounted Harddrive.
Example:
ln -s /media/usb-device/logs/auth.log /var/log/auth.log
The logging works fine. But fail2ban seems not to like that. When I enable my ssh-monitoring in my /etc/fail2ban/jail.local file,
# [sshd]
enabled = true
bantime = 3600
fail2ban crash during executing this command systemctl restart fail2ban.service
I have tried to hardcode the path:
# logpath = %(sshd_log)s
logpath = /media/usb-devive/logs/auth.log
But fail2ban throws the same error:
fail2ban.service - Fail2Ban Service
Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2018-04-28 20:42:33 CEST; 45s ago
Docs: man:fail2ban(1)
Process: 3014 ExecStop=/usr/bin/fail2ban-client stop (code=exited, status=0/SUCCESS)
Process: 3045 ExecStart=/usr/bin/fail2ban-client -x start (code=exited, status=255)
Main PID: 658 (code=killed, signal=TERM)
Apr 28 20:42:33 raspberrypi systemd[1]: fail2ban.service: Service hold-off time over, scheduling restart.
Apr 28 20:42:33 raspberrypi systemd[1]: Stopped Fail2Ban Service.
Apr 28 20:42:33 raspberrypi systemd[1]: fail2ban.service: Start request repeated too quickly.
Apr 28 20:42:33 raspberrypi systemd[1]: Failed to start Fail2Ban Service.
Apr 28 20:42:33 raspberrypi systemd[1]: fail2ban.service: Unit entered failed state.
Apr 28 20:42:33 raspberrypi systemd[1]: fail2ban.service: Failed with result 'exit-code'.
Any ideas?
"devive" in the logpath is spelt incorrectly