Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

-2 votes
0 answers
42 views
help with pvpgn server
Help me with pvpgn server run? I installed it on FreeBSD and, now I don't know how to start the service. I install in /build/src/bnetd ./bnetd and it didn't work. Can someone who understands FreeBSD give me a little help? to download and how to install it https://github.com/pvpgn/pvpgn-server i need...
Help me with pvpgn server run? I installed it on FreeBSD and, now I don't know how to start the service. I install in /build/src/bnetd ./bnetd and it didn't work. Can someone who understands FreeBSD give me a little help? to download and how to install it https://github.com/pvpgn/pvpgn-server i need start service now i how is possible??
Willian (97 rep)
Jul 31, 2025, 05:00 PM • Last activity: Aug 1, 2025, 07:18 PM
6 votes
1 answers
3948 views
X2Go: How to enable/disable
[Documentation](https://wiki.archlinux.org/index.php/X2go#Start_X2Go_server_daemon) and various internet answers suggest `x2goserver` will have a service on systemd systems which can be started (or stopped, etc) with `systemctl start x2goserver`. However, there is no such service on my system (Fedor...
[Documentation](https://wiki.archlinux.org/index.php/X2go#Start_X2Go_server_daemon) and various internet answers suggest x2goserver will have a service on systemd systems which can be started (or stopped, etc) with systemctl start x2goserver. However, there is no such service on my system (Fedora 30 MATE): > Unit x2goserver.service could not be found. There is also no process by this name except for x2gocleansessions: $ pgrep -la x2go 1808 /usr/bin/perl /usr/sbin/x2gocleansessions Yet, X2Go is working. Has its process or service been named something else now? How can X2Go be turned off or on?
adatum (1241 rep)
May 22, 2019, 06:43 PM • Last activity: Jul 31, 2025, 08:07 PM
0 votes
2 answers
1232 views
Trouble with keeping process launched by systemd service alive
I am trying to to get my first `systemd` service working as desired. Here is what I have: `gateway-watchdog.service`: ``` # A systemd service for the Gateway Watchdog [Unit] Description=gateway-watchdog: Watchdog to ensure that Gateway (gateway.py) is running [Service] Type=simple User=root WorkingD...
I am trying to to get my first systemd service working as desired. Here is what I have: gateway-watchdog.service:
# A systemd service for the Gateway Watchdog

[Unit]
Description=gateway-watchdog: Watchdog to ensure that Gateway (gateway.py) is running

[Service]
Type=simple
User=root
WorkingDirectory=/home/ubuntu/lora_gateway/
ExecStart=/home/ubuntu/lora_gateway/watchdog.sh

[Install]
WantedBy=multi-user.target
gateway-watchdog.timer:
[Unit]
Description=gateway-watchdog: Timer to run the associated gateway-watchdog service

[Timer]
# Run service 1 minute after boot
OnBootSec=1min
# Run service 15 minutes after the last run
OnUnitActiveSec=30s

[Install]
WantedBy=timers.target
watchdog.sh has these lines (contained in some if statements):
#!/bin/bash
...
if [[condition]]; then
    command="python3 gateway.py"
        # Process needs to be run in the background with '&'. If it isn't, the systemd service will treat this script
        # as still running and so not re-run it at the time specified by the timer service.
    echo "2 $(date +'%F %T'): Running: $command" >> $LOG_FILE_PATH
    eval "$command"
        # Command must be run using eval. If it isn't, the ampersand at the end of the command is effectively ignored
    exit
fi
What I need: The service will run watchdog.sh. If the if conditions in the script are true, watchdog.sh will launch python3 gateway.py as a separate process and then exit, and the service will no longer be considered active so that it will run again 30 seconds later. Through various combinations of different service Types (I've tried simple, oneshot, and forking), using & at the end of ExecStart and/or my command line, and/or using nohup, I am able to either launch and keep gateway.py alive, or have the service run every 30 seconds, but not both. When python3 gateway.py stays alive, it always stays part of the service's CGroup, so the service stays active (running). How can I change this behavior to achieve what I'm trying to do? Any thoughts are greatly appreciated. **EDIT**: I have updated the file contents above to reflect changes made based on suggestions from U. With the files as given above, sudo systemctl status gateway-watchdog.service gives:
● gateway-watchdog.service - gateway-watchdog: Watchdog to ensure that Gateway (gateway.py) is running
     Loaded: loaded (/etc/systemd/system/gateway-watchdog.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-01-13 01:45:25 UTC; 8s ago
TriggeredBy: ● gateway-watchdog.timer
   Main PID: 30684 (watchdog.sh)
      Tasks: 3 (limit: 4435)
     CGroup: /system.slice/gateway-watchdog.service
             ├─30684 /bin/bash /home/ubuntu/lora_gateway/watchdog.sh
             └─30696 python3 gateway.py

Jan 13 01:45:25 ubuntu systemd: Started gateway-watchdog: Watchdog to ensure that Gateway (gateway.py) is running.
Good: The gateway.py process stays running. Bad: The service does not run again 30 seconds later, because the previous run is still active. If I put the & back into command="python3 gateway.py &", sudo systemctl status gateway-watchdog.service gives:
● gateway-watchdog.service - gateway-watchdog: Watchdog to ensure that Gateway (gateway.py) is running
     Loaded: loaded (/etc/systemd/system/gateway-watchdog.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Thu 2022-01-13 01:49:05 UTC; 6s ago
TriggeredBy: ● gateway-watchdog.timer
    Process: 33724 ExecStart=/home/ubuntu/lora_gateway/watchdog.sh (code=exited, status=0/SUCCESS)
   Main PID: 33724 (code=exited, status=0/SUCCESS)

Jan 13 01:49:05 ubuntu systemd: Started gateway-watchdog: Watchdog to ensure that Gateway (gateway.py) is running.
Jan 13 01:49:05 ubuntu systemd: gateway-watchdog.service: Succeeded.
Good: The service is inactive, so it does run again 30 seconds later. Bad: The python3 gateway.py process dies immediately.
nabelekt (1 rep)
Jan 12, 2022, 04:31 AM • Last activity: Jul 29, 2025, 04:36 AM
0 votes
3 answers
2504 views
Starting tomcat hangs on boot , but run successfully in command line
I installed tomcat9 on ubuntu 16.04, which start normally on command line, sudo /usr/local/tomcat9/startup.sh and all projects in webapps can be loaded. However, it always hangs on loading "webapps/docs" if i try to start it on OS boot. Here's the snapshot of catalina.out: [![catalina.out][1]][1] --...
I installed tomcat9 on ubuntu 16.04, which start normally on command line, sudo /usr/local/tomcat9/startup.sh and all projects in webapps can be loaded. However, it always hangs on loading "webapps/docs" if i try to start it on OS boot. Here's the snapshot of catalina.out: catalina.out ---------- I've tried 3 kinds of methods to auto-start tomcat. 1. setup a service in diretory init.d ------------------------------------- 1) Copy file "catalina.sh" into "/etc/init.d", and rename it to "tomcat" 2) add Evirement Virables to this file: CATALINA_HOME=/usr/local/tomcat9 JAVA_HOME=/usr/lib/jvm/jdk1.8.0_111 3) use command service tomcat start 2. setup a service in systemd ----------------------------- 1) edit file "/etc/systemd/system/tomcat.service" enter image description here 2) load configuration in command line systemctl daemon-reload systemctl start tomat 3) check status systemctl status tomat which shows tomcat service start successfully 3. Setup "rc.local" service first, and add start script in "rc.local" file ------------------------------------------------------------------------ 1) edit file "/etc/systemd/system/rc-local.servic" [Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target 2) edit file "/etc/rc.local " sudo /usr/local/tomcat9/bin/startup.sh 3) enable "rc.local" service sudo systemctl enable rc-local.service 4) reboot All these methods gave the same result: tomcat started, but loading webapps imcomplete, hanging on loading the first app "docs". I have no idea on it, please help.
songofhawk (1 rep)
Mar 3, 2017, 12:15 AM • Last activity: Jul 27, 2025, 12:01 PM
0 votes
1 answers
2385 views
Systemd specifying service name dynamically
Is there a way of setting a service name dynamically in a service file? I am running several instances of a service, where all services uses different input arguments. For debugging this is not optimal as all services are called the same and it can be tedious finding out which service is actually co...
Is there a way of setting a service name dynamically in a service file? I am running several instances of a service, where all services uses different input arguments. For debugging this is not optimal as all services are called the same and it can be tedious finding out which service is actually complaining. So what I want is to give the service a unique name for a given input. Systemds service files support this by changing the arg in
by setting the prefix "@" where the second argument will be the arg value. Information about
command and the **@** prefix: https://www.freedesktop.org/software/systemd/man/systemd.service.html So this is what I have so far in my service file:
ExecStart=@/usr/bin/foo foo-%I %I
The input argument is a file, so it will be called something like bar-123.json. This works and the service name will be foo-bar-123.json when I use top, ps or the QA tools we are using. The input files are created by another service that also starts the "foo" service instance using systemctl dbus api. However having the service called foo-bar-123.json is not the best and instead I would like to call is foo-bar. I have tried running, as a test:
**ExecStartPre=/bin/sh -c 'export NAME=bar'**
**ExecStart=@/usr/bin/foo foo-${NAME} %I**
But then the name will be "foo-". Am guessing this is to be expected as the service file is not a shell script, however that was the only solution I could think of. Other solution to the problem are also welcomed. I know that PR_SET_NAME in the prctl function should also change the name of the process but I am not sure who they relates to each other. The reason I don't want to use the prctl function is that is says that the name only can be 16 bytes long including the null byte, this is a limitation that I would be nice not to have.
Adam Nilsson (1 rep)
Apr 12, 2021, 03:54 PM • Last activity: Jul 27, 2025, 06:08 AM
0 votes
1 answers
2956 views
On systemctl start, "Failed to start gitlab-runner.service: Unit is not loaded properly: Bad message."
Whenever I run `systemctl start gitlab-runner.service` I get, systemctl start gitlab-runner.service Failed to start gitlab-runner.service: Unit is not loaded properly: Bad message. See system logs and 'systemctl status gitlab-runner.service' for details. How can I find more information about this er...
Whenever I run systemctl start gitlab-runner.service I get, systemctl start gitlab-runner.service Failed to start gitlab-runner.service: Unit is not loaded properly: Bad message. See system logs and 'systemctl status gitlab-runner.service' for details. How can I find more information about this error, what does this mean?
Evan Carroll (34663 rep)
Mar 22, 2020, 04:35 PM • Last activity: Jul 26, 2025, 03:09 AM
1 votes
1 answers
353 views
On my Ubuntu-based distro (Linux Lite), how to auto delete all network connections, disable Wi-Fi and networking as part of booting process?
My end goal here is to have no saved network connections, no enabled Wi-Fi or networking each time I boot up my computer, so that I have to go through a sequence of steps in order to access internet. The purpose is to moderate my sceen behavior. My current way is through creating a script that uses...
My end goal here is to have no saved network connections, no enabled Wi-Fi or networking each time I boot up my computer, so that I have to go through a sequence of steps in order to access internet. The purpose is to moderate my sceen behavior. My current way is through creating a script that uses 'nmcli' and run at startup using crontab's @reboot. But It's not working. Here is the script
#!/bin/bash

# this script disables wifi and networking

echo 'Deleting all existing connections...'
# nmcli is a command-line interface for networkmanager
# 'nmcli connection delete' -> simply deletes a connection by ID, UUID or others
# we use 'nmcli connection show' along with some filter to extract UUIDs for all conections
# TODO enable deletion of a particular connection
#connections_list=$(nmcli connection show | grep -oP '\s(\S+-\S+-\S+-\S+-\S+)\s')
#for connection in "$connections_list"; do 
    #nmcli connection show "$connection"
    #if (($? != 0)); then 
        #echo "something went wrong while deleting connection $connection" >&2
        #exit 1
    #fi
#done
nmcli connection delete $(nmcli connection show | grep -oP '\s(\S+-\S+-\S+-\S+-\S+)\s') 
if [[ $? -ne 0 ]]; then
    echo 'shit happens while deleting connections' >&1 
    exit 1
fi
echo 'All connections were deleted! now, you will have to type SSID and password again'

echo 

echo 'Disabling Wi-Fi...'
if ! nmcli radio wifi off; then 
    echo 'nmcli, command disabling wifi, is not satisfied for some reason' >&2
    exit 1
fi 
echo 'Wi-Fi is disabled.'

echo 

echo 'Disabling networking...'
if ! nmcli networking off; then 
    echo 'nmcli, command disabling networking, is not happy' >&2 
    exit 1
fi
echo 'Networking is disabled.'

echo

echo 'All is good'
echo '==============================='
exit 0
Here is the corntab line (created using sudo crontab -e) @reboot /home/noor/bin/go-offline-1.0 >> /home/noor/go-offline.log 2>&1 Contents of log file:
Deleting all existing connections...
Error: NetworkManager is not running.
Error: NetworkManager is not running.
shit happens while deleting connections
I guess that at the point of executing my script in the boot process, NetwrokManager is not yet activated. Also after a quick exchange with ChatGPT, I tried to make script run as part of the shut down process rather than at startup using systemlc or sth, but it didn't work for some reason. I don't see reason to mention its details. I had an idea to alias poweroff command so that it executes my script then shut down the computer. I don't know whether it's a good idea but I am looking for a better solution anyway. I welcome all useful responses related to any part of this, including fixes to this method or completely different approach. Thank you!
mark coder (49 rep)
Jul 21, 2025, 11:14 AM • Last activity: Jul 21, 2025, 12:25 PM
0 votes
1 answers
2002 views
opening a terminal with a command on startup in debian
I have an application which is an object file (obtained from a c source code). When I run this application from the terminal it works fine. I want to run this application on system start up. Since all the log data currently I am printing on the terminal, I want to open the terminal and run this appl...
I have an application which is an object file (obtained from a c source code). When I run this application from the terminal it works fine. I want to run this application on system start up. Since all the log data currently I am printing on the terminal, I want to open the terminal and run this application in terminal (so that I can see the live log and also give input to my application from terminal). After searching some tutorials I am able to create a service which runs a shell script on startup. I modified this script to open a terminal and run the application. If I run the shell script only from the terminal it works well. But when I am running the script from service I am getting following warning:
(x-terminal-emulator:16048): Gtk-WARNING **: cannot open display:
Where am I making mistake? Here I am using beaglebone black running with debian. * This is my service file (application.service)
-ini
    [Unit]
    Description=application setup
    
    [Service]
    WorkingDirectory=/root/application/
    ExecStart=/root/application/start_application
    SyslogIdentifier=application
    Restart=on-failure
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target
* Here is start_application.sh
-shell
    #! /bin/sh
    #
    # start_app_server
    #

    echo "Starting application server"
    x-terminal-emulator -e "app_server/a.out"

    echo Done
Edge G (1 rep)
Aug 11, 2015, 10:52 AM • Last activity: Jul 19, 2025, 03:10 PM
2 votes
3 answers
5459 views
Does there exist a PID for each tomcat service? If so, then can we find the service name from that PID of the running tomcat service?
I am working on linux server. I want to know whether there exists a PID for each tomcat service running on any server. If a PID for a particular tomcat service exists, then can we find the service name corresponding to that PID? Can we list all the tomcat services running on the server?
I am working on linux server. I want to know whether there exists a PID for each tomcat service running on any server. If a PID for a particular tomcat service exists, then can we find the service name corresponding to that PID? Can we list all the tomcat services running on the server?
Aditya (41 rep)
Jun 29, 2017, 11:56 AM • Last activity: Jul 17, 2025, 05:02 PM
2 votes
2 answers
2872 views
Installing MySQL on CentOS throws error that cannot find mysqld.sock
I have `yum install mysql` in **CentOS 6.4**. Now, when I use `mysql` command, it throws the following error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' When I check the directory there is no mysql folder. How should I solve this problem? It'...
I have yum install mysql in **CentOS 6.4**. Now, when I use mysql command, it throws the following error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' When I check the directory there is no mysql folder. How should I solve this problem? It's worth mentioning when I do service mysql start (or with mysqld) it errors **unrecognized service**. I should mention that I have changed the path in my.cnf but nothing happens. The problem is that no *.sock file exists at all. **Update**: Results of checking mysql process with mysqladmin -u root -p status returns: mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists! Also when I directly want to run /etc/init.d/mysqld it errors that it cannot resolve the ip (localhost.localdomain). **Second Update:** I have run the command [root@localhost /]# rpm -qa | grep mysql and it returns: mysql-libs-5.1.73-3.el6_5.x86_64 mysql-libs-5.1.73-3.el6_5.i686 mysql-5.1.73-3.el6_5.x86_64 mysql-server-5.1.73-3.el6_5.i686
Mostafa Talebi (185 rep)
Jan 4, 2015, 07:35 AM • Last activity: Jul 13, 2025, 10:07 AM
0 votes
0 answers
28 views
How to make caddy run in/from a directory as a service in Ubuntu 20.04.2?
I installed caddy with "sudo apt install caddy" and have everything setup and working, but I also want to run caddy automatically from boot. When I use ``` sudo systemctl enable caddy ``` and reboot, I get a 403 error from my website. To fix this I kill caddy and use ``` cd /home/user/Desktop/websid...
I installed caddy with "sudo apt install caddy" and have everything setup and working, but I also want to run caddy automatically from boot. When I use
sudo systemctl enable caddy
and reboot, I get a 403 error from my website. To fix this I kill caddy and use
cd /home/user/Desktop/websida
then
sudo caddy run
, then it's fixed, no errors but I have to do this every time I boot, hence why I want it to run as a service but in another directory: /home/user/Desktop/websida
MR_MEME53 (1 rep)
Jul 1, 2025, 08:07 AM
0 votes
1 answers
4271 views
Error: could not open `user_jvm_args.txt`
This is my first time making a bash script into a service and I'm running into an error where the service fails because it can't open a text file that is used for java arguments (user_jvm_args.txt). I assume there's some sort of permissions issue going on, but I'm at a loss. Anything helps as I'm tr...
This is my first time making a bash script into a service and I'm running into an error where the service fails because it can't open a text file that is used for java arguments (user_jvm_args.txt). I assume there's some sort of permissions issue going on, but I'm at a loss. Anything helps as I'm trying to get better and learn. Thanks! Here's the service file:
[Service]
ExecStart=/home/ethan/ATM9-Server/run.sh
Here's the run.sh bash script:
#!/usr/bin/env sh

java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.20.1-47.1.3/unix_args.txt "$@"
Here's the user_jvm_args.txt file that is in the same folder as the run.sh script:
# Xmx and Xms set the maximum and minimum RAM usage, respectively.
# They can take any number, followed by an M or a G.
# M means Megabyte, G means Gigabyte.
# For example, to set the maximum to 3GB: -Xmx3G
# To set the minimum to 2.5GB: -Xms2500M
# A good default for a modded server is 4GB.

-Xms1G
-Xmx10G
-XX:+UseG1GC
-XX:+ParallelRefProcEnabled
-XX:MaxGCPauseMillis=200
-XX:+UnlockExperimentalVMOptions
-XX:+DisableExplicitGC
-XX:+AlwaysPreTouch
-XX:G1NewSizePercent=30
-XX:G1MaxNewSizePercent=40
-XX:G1HeapRegionSize=8M
-XX:G1ReservePercent=20
-XX:G1HeapWastePercent=5
-XX:G1MixedGCCountTarget=4
-XX:InitiatingHeapOccupancyPercent=15
-XX:G1MixedGCLiveThresholdPercent=90
-XX:G1RSetUpdatingPauseTimePercent=5
-XX:SurvivorRatio=32
-XX:+PerfDisableSharedMem
-XX:MaxTenuringThreshold=1
Most of those are defaults, and the only ones I changed were -Xms and -Xmx. Here's the that error occurs as it shows in the logs:
Nov 03 15:44:43 ATM9-Server-Temp systemd: Started run.service.
Nov 03 15:44:43 ATM9-Server-Temp run.sh: Error: could not open `user_jvm_args.txt'
Nov 03 15:44:43 ATM9-Server-Temp systemd: run.service: Main process exited, code=exited, status=1/FAILURE
Nov 03 15:44:43 ATM9-Server-Temp systemd: run.service: Failed with result 'exit-code'.
EChumley1310 (1 rep)
Nov 3, 2023, 09:04 PM • Last activity: Jun 30, 2025, 10:04 AM
4 votes
1 answers
3920 views
Unknown runlevel on Ubuntu 14.04, services not starting on boot
I rent a VPS from a VPS company and run an Ubuntu 14.04 web server there. Recently it had to be suspended by my provider for a while. After the suspension period (1-2 days), the VPS boots, but cannot acquire any runlevels. root@vps:/# runlevel unknown This, in turn, means no Upstart services are sta...
I rent a VPS from a VPS company and run an Ubuntu 14.04 web server there. Recently it had to be suspended by my provider for a while. After the suspension period (1-2 days), the VPS boots, but cannot acquire any runlevels. root@vps:/# runlevel unknown This, in turn, means no Upstart services are starting on boot, as the "useful stuff" requires runlevel . I can start individual services manually with initctl, unless they have dependencies which the boot did not start automatically. I cannot find anything useful/understandable from logs. Please do ask if you want specific log entries and I can try to find them. The server is (was) running PHP7, Nginx, MySQL, Redis, Minecraft Server, Mumble Server. The server was operating fine (and survived multiple reboots) before the suspension period. Here is my initctl list after a fresh reboot: http://pastebin.com/fcfcnxBU . Please do ask for specific details as I'm not entirely sure where to look for them (e.g. log files, debug artifacts, files and directories, etc.). **EDIT**: some progress via tinkering: It seems the filesystem and/or network stack is not started correctly when booting. When I do the following: $ ifup --all $ initctl emit static-network-up $ initctl emit filesystem ... Ctrl-C to exit loop $ initctl emit local-filesystems Then I get $ runlevel >N 2 And my server services (at least most of them) are running normally. I'll check if there is a single command of these that makes the boot init sequence continue normally. EDIT2: - ifup --all brings up a venet0:0 which is tied to the VPS' public static IP. - emit static-network-up does nothing. - emit filesystem + Ctrl-C starts - rsyslog - ssh - minecraft-server - cron - xinetd - console - tty2 - upstart-file-bridge - mysql and stops - plymouth - plymouth-upstart-bridge - emit local-filesystems starts - avahi-daemon - systemd-logind - mountall.sh - dbus - networking and something called network-interface-security (network-interface/lo) start/running disappears.
ojrask (141 rep)
Jul 18, 2016, 09:45 PM • Last activity: Jun 26, 2025, 05:04 AM
2 votes
2 answers
19237 views
Default-Start contains no runlevels
I am trying to make my custom made daemon run at startup and when I call `update-rc.d ydcd enable` I get the error update-rc.d: using dependency based boot sequencing update-rc.d: error: MyDaemon Default-Start contains no runlevels, aborting. I'm running Debian wheezy, init is SysVinit. Googling it...
I am trying to make my custom made daemon run at startup and when I call update-rc.d ydcd enable I get the error update-rc.d: using dependency based boot sequencing update-rc.d: error: MyDaemon Default-Start contains no runlevels, aborting. I'm running Debian wheezy, init is SysVinit. Googling it does not give me any valuable info, so I come here as a last resort. What's going on here? What do I need to change in my init.d script in order to make this work? Edit: Here's the script: #!/bin/bash # #ydcd.daemon # # chkconfig: 2345 85 15 # description: MyServiceName # processname: MyServiceName # source function library . /lib/lsb/init-functions RETVAL=0 NAME=ydcd.daemon # YOU CAN SET ANY PATH BUT IS RECOMENDED TO USE THE DISTRO'S STANDARD ONE. DAEMON=/home/debian/yd_cd/$NAME prog=$(basename $DAEMON) lockfile=/var/lock/$NAM SVC_FILE=$DAEMON start() { if [ -f $SVC_FILE ]; then #reset echo -n "Starting "$SVC_FILE": " RETVALS=$(start-stop-daemon -S -b -x $SVC_FILE -- -r) Count=${#RETVALS[@]} RETVAL="[FAIL]" if [ $Count -eq 0 ]; then RETVAL="[OK]" elif [ $Count -eq 1 ]; then if [ ${#RETVALS} -eq 0 ]; then RETVAL="[OK]" else iStart=${#SVC_FILE} iLength=${#RETVALS} Response=${RETVALS:(iStart+1):7} RETVAL=$Response if [ "$Response" == "already" ]; then RETVAL="[OK]" fi fi fi echo $RETVAL return 0 else echo $SVC_ALIAS" not installed" $SVC_DIR exit 2; fi } stop() { echo -n "Shutting down "$SVC_FILE":" RETVALS=$(start-stop-daemon -K -x $SVC_FILE -- s) #additional PROCKILLS=$(killall -w -q -e $SVC_PROCESS_NAME $SVC_FILENAME) Count=${#RETVALS[@]} Index=0 RETVAL="[FAIL]" if [ $Count -eq 1 ]; then if [ ${#RETVALS} -eq 0 ]; then RETVAL="[OK]" else Response=${RETVALS:0:2} RETVAL=$Response if [ "$Response" == "No" ]; then RETVAL="[OK]" fi fi else RETVAL="[OK]" fi echo $RETVAL return 0 } case "$1" in start) start ;; stop) stop ;; status) status $SVC_SERVICE_SCRIPT ;; restart) stop start ;; *) echo $SVC_ALIAS" [Invalid Startup Parameters]" echo "Usage: {start|stop|status|restart}" exit 1 ;; esac exit $?
vaid (129 rep)
Jan 24, 2016, 02:17 AM • Last activity: Jun 26, 2025, 12:04 AM
1 votes
2 answers
1977 views
How can I make apache to start up automatically on linux mint?
I have installed Linux Mint 18.1 Serena and I have XAMPP 5.6.28-1 on my computer. After I turn on my computer, I must run the XAMPP control panel and I must start Apache and MySQL manually. Does anyone know how this can be done automatically? I don't want to turn on Apache and MySql every time when...
I have installed Linux Mint 18.1 Serena and I have XAMPP 5.6.28-1 on my computer. After I turn on my computer, I must run the XAMPP control panel and I must start Apache and MySQL manually. Does anyone know how this can be done automatically? I don't want to turn on Apache and MySql every time when I start / restart my computer.
user2417624
Jan 22, 2017, 02:18 PM • Last activity: Jun 23, 2025, 04:03 AM
49 votes
3 answers
120670 views
The rc0.d,rc1.d,... directories in /etc
I'm running Ubuntu where I have the directories `/etc/rc0.d`, `/etc/rc1.d`, `/etc/rc2.d`, ..., `/etc/rc6.d`. Example files from my machine: directory example symlinks in the dir ------------------------------------------ /etc/rc1.d: K76dovecot, K77ntp /etc/rc2.d: S23ntp, S24dovecot /etc/rc3.d: S23nt...
I'm running Ubuntu where I have the directories /etc/rc0.d, /etc/rc1.d, /etc/rc2.d, ..., /etc/rc6.d. Example files from my machine: directory example symlinks in the dir ------------------------------------------ /etc/rc1.d: K76dovecot, K77ntp /etc/rc2.d: S23ntp, S24dovecot /etc/rc3.d: S23ntp, S24dovecot /etc/rc4.d: S23ntp, S24dovecot /etc/rc5.d: S23ntp, S24dovecot Questions: 1. What's the purpose of the multiple "rc" directories? 2. Why did Ubuntu install duplicates of dovecot and ntp into all the directories except rc0.d and rc6.d? 3. If they are specified multiple times like above, are they actually executed multiple times? 4. Can you tell from the above in what order dovecot and ntp will execute at startup? 5. What is the proper way to tell Ubuntu to always execute ntp before dovecot at startup?
roger.james (605 rep)
Jul 20, 2013, 01:06 PM • Last activity: Jun 21, 2025, 07:54 AM
1 votes
2 answers
27311 views
Systemd service fails with exit-code 2: Start request repeated too quickly
I created a ClamAV on-access scanning systemd service, to be permanent so that I can enable, start and then leave it, without having to touch it again. I can manually start the service, and it works fine. But it keeps failing to start automatically after login as expected. In both cases, there are n...
I created a ClamAV on-access scanning systemd service, to be permanent so that I can enable, start and then leave it, without having to touch it again. I can manually start the service, and it works fine. But it keeps failing to start automatically after login as expected. In both cases, there are no active network connections. I believe the following journal output (found in last ouput section of the post) could be a clue:
rc.local: ERROR: ClamClient: could not connect to remote clam daemon, Couldn't connect to server
rc.local: ERROR: Clamonacc: daemon is local, but a connection could not be established
But I still don't why I'm able to manually start the service, but not have it start automatically. # System info
$ uname -a

Linux debian 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux
# rc-local.service file
$ sudo cat /etc/systemd/system/rc-local.service

[Unit]
Description=ClamAV On-Access Scanner
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
User=root
Require=network.target
RemainAfterExit=yes
ExecStart=/etc/rc.local start
TimeoutSec=200
Restart=on-failure
StartLimitInterval=10

[Install]
WantedBy=multi-user.target
# rc.local script
$ sudo cat /etc/rc.local

#!/bin/sh -e

/usr/bin/clamonacc --log=/var/log/clamav/clamonacc.log

exit 0
# Status after logging in
● rc-local.service - ClamAV On-Access Scanner
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: failed (Result: exit-code) since Wed 2020-10-21 08:06:33 BST; 12min ago
  Process: 1483 ExecStart=/etc/rc.local start (code=exited, status=2)

Oct 21 08:06:33 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 08:06:33 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 5.
Oct 21 08:06:33 debian systemd: Stopped ClamAV On-Access Scanner.
Oct 21 08:06:33 debian systemd: rc-local.service: Start request repeated too quickly.
Oct 21 08:06:33 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 08:06:33 debian systemd: Failed to start ClamAV On-Access Scanner.
# Status after manually starting service
● rc-local.service - ClamAV On-Access Scanner
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (running) since Wed 2020-10-21 08:23:04 BST; 52s ago
  Process: 7171 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
 Main PID: 7173 (clamonacc)
    Tasks: 8 (limit: 4915)
   Memory: 2.6M
   CGroup: /system.slice/rc-local.service
           └─7173 /usr/bin/clamonacc --log=/var/log/clamav/clamonacc.log

Oct 21 08:23:04 debian systemd: Starting ClamAV On-Access Scanner...
Oct 21 08:23:04 debian systemd: Started ClamAV On-Access Scanner.
# Journal
$ sudo journalctl | grep rc-local

Oct 21 08:06:22 debian systemd: /etc/systemd/system/rc-local.service:7: Unknown lvalue 'Require' in section 'Service', ignoring
Oct 21 08:06:31 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 08:06:31 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 08:06:31 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 08:06:31 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 1.
Oct 21 08:06:31 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 08:06:31 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 08:06:32 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 08:06:32 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 2.
Oct 21 08:06:32 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 08:06:32 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 08:06:32 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 08:06:32 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 3.
Oct 21 08:06:32 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 08:06:32 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 08:06:32 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 08:06:32 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 4.
Oct 21 08:06:32 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 08:06:32 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 08:06:33 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 08:06:33 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 5.
Oct 21 08:06:33 debian systemd: rc-local.service: Start request repeated too quickly.
Oct 21 08:06:33 debian systemd: rc-local.service: Failed with result 'exit-code'.
$ sudo journalctl | grep rc.local

Oct 21 13:47:57 debian rc.local: ERROR: ClamClient: could not connect to remote clam daemon, Couldn't connect to server
Oct 21 13:47:57 debian rc.local: ERROR: Clamonacc: daemon is local, but a connection could not be established
Oct 21 13:47:57 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 13:47:57 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 13:47:57 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 13:47:57 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 1.
Oct 21 13:47:57 debian rc.local: ERROR: ClamClient: could not connect to remote clam daemon, Couldn't connect to server
Oct 21 13:47:57 debian rc.local: ERROR: Clamonacc: daemon is local, but a connection could not be established
Oct 21 13:47:57 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 13:47:57 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 13:47:58 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 13:47:58 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 2.
Oct 21 13:47:58 debian rc.local: ERROR: ClamClient: could not connect to remote clam daemon, Couldn't connect to server
Oct 21 13:47:58 debian rc.local: ERROR: Clamonacc: daemon is local, but a connection could not be established
Oct 21 13:47:58 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 13:47:58 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 13:47:58 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 13:47:58 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 3.
Oct 21 13:47:58 debian rc.local: ERROR: ClamClient: could not connect to remote clam daemon, Couldn't connect to server
Oct 21 13:47:58 debian rc.local: ERROR: Clamonacc: daemon is local, but a connection could not be established
Oct 21 13:47:58 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 13:47:58 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 13:47:58 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 13:47:58 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 4.
Oct 21 13:47:58 debian rc.local: ERROR: ClamClient: could not connect to remote clam daemon, Couldn't connect to server
Oct 21 13:47:58 debian rc.local: ERROR: Clamonacc: daemon is local, but a connection could not be established
Oct 21 13:47:58 debian systemd: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Oct 21 13:47:58 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 13:47:59 debian systemd: rc-local.service: Service RestartSec=100ms expired, scheduling restart.
Oct 21 13:47:59 debian systemd: rc-local.service: Scheduled restart job, restart counter is at 5.
Oct 21 13:47:59 debian systemd: rc-local.service: Start request repeated too quickly.
Oct 21 13:47:59 debian systemd: rc-local.service: Failed with result 'exit-code'.
Oct 21 13:48:14 debian sudo:   squire : TTY=pts/0 ; PWD=/home/squire ; USER=root ; COMMAND=/usr/sbin/service rc-local status
Oct 21 13:54:30 debian sudo:   squire : TTY=pts/1 ; PWD=/home/squire ; USER=root ; COMMAND=/usr/sbin/service rc-local status
5am (333 rep)
Oct 21, 2020, 07:37 AM • Last activity: Jun 17, 2025, 01:06 PM
2 votes
2 answers
8289 views
Running a systemd service with RootDirectory= and access /bin binaries
I'm trying to utilize some of the systemd helpers to [chroot(2)](http://man7.org/linux/man-pages/man2/chroot.2.html) the process using `RootDirectory=`. It's a rudimentary Python script that lives under `/srv/http` that hosts a web server. It has a shebang `#!/usr/bin/python` *(and I've also tried d...
I'm trying to utilize some of the systemd helpers to [chroot(2)](http://man7.org/linux/man-pages/man2/chroot.2.html) the process using RootDirectory=. It's a rudimentary Python script that lives under /srv/http that hosts a web server. It has a shebang #!/usr/bin/python *(and I've also tried different combinations)* The service file is also quite simple:
[Unit]
Wants=network-online.target
After=network-online.target

AssertPathExists=/srv/http

[Service]
Type=simple
Restart=always
RestartSec=10

RootDirectory=/srv/http
PrivateTmp=true

ExecStart=/server.py
PIDFile=/run/miniweb.pid

[Install]
WantedBy=multi-user.target
The log clearly says it can't find the executable:
Mar 11 19:23:49 bigrigv2 systemd: testweb.service: Failed to execute /server.py: No such file or directory
Mar 11 19:23:49 bigrigv2 systemd: testweb.service: Failed at step EXEC spawning /server.py: No such file or directory
It's marked as executable:
-rwxr-xr-x 1 anton anton  650 Mar 11 19:06 server.py
I also tried ExecStart=/bin/python /srv/http/server.py and other variations. I'm not entirely sure I even understand the concept of RootDirectory and how to properly execute for instance Python or other binaries from a chrooted service script. My assumption is that before executing the service, it chroot:s in to /srv/http after which the service won't be able to back out and execute Python in this case. Which would make sense, but then I don't quite get why /server.py isn't found. And how would you execute things that are dependent on other binaries? Most solutions mention utilizing the language (C for instance) chroot and control it from the application, but then I don't understand the point of offering chroot in the service script for other things than very limited bash scripts or standalone binaries. Probably an extremely easy problem, but I'm quite lost and any help would be appreciated!
Torxed (3727 rep)
Mar 11, 2021, 07:13 PM • Last activity: Jun 17, 2025, 12:48 PM
1 votes
1 answers
3777 views
systemctl authenticating as other user
I have made this script that allows non-root access for a directory so a program can make changes to files in said directories. This .service has worked on a few machines and even on the same machine in the past however after a fresh reinstall of arch linux `systemd`/`systemctl` is "Authenticating a...
I have made this script that allows non-root access for a directory so a program can make changes to files in said directories. This .service has worked on a few machines and even on the same machine in the past however after a fresh reinstall of arch linux systemd/systemctl is "Authenticating as: mpd". The weird thing is when i use sudo to start it. It will work but using enable doesn't persist on reboot. I'm don't really know what I'm doing so i apologize I'm gonna read up on systemd after the semester.
[oddstap@Arch2019 ~]$ systemctl enable brightlight.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ====
Authentication is required to manage system service or unit files.
Authenticating as: mpd
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ====
Failed to enable unit: Access denied
[oddstap@Arch2019 ~]$
I'm not really sure why this is I've tried a few things like using the --user flag and then giving the exact directory. It has mixed results/ Ive also tried putting the service file in /etc/systemd/system that just does the same thing.
[oddstap@Arch2019 /usr/lib/systemd/system]$ systemctl --user enable /usr/lib/systemd/system/brightlight.service
Removed /home/oddstap/.config/systemd/user/multi-user.target.wants/brightlight.service.
Created symlink /home/oddstap/.config/systemd/user/multi-user.target.wants/brightlight.service → /usr/lib/systemd/system/brightlight.service.
[oddstap@Arch2019 /usr/lib/systemd/system]$
I've seen a similar issue I think [on Server Fault](https://serverfault.com/questions/841306/authentication-is-required-to-manage-system-services-or-units) . Here is the .service file I posted it here I'm pretty sure this is not the cause but I could be wrong. I'm gonna try to fix this but if anyone got any ideas let me know. Not having systemd enabling scripts is making my life hard.
[Unit]
Description Hopefully will be a solution for you reading.
Before nodered.service

[Service]
Type oneshot
User root
ExecStart=/bin/bash -c "/bin/chmod a+w /sys/class/backlight/intel_backlight/*"

[Install]
WantedBy=multi-user.target
mr Stap (61 rep)
Dec 2, 2019, 06:34 AM • Last activity: Jun 15, 2025, 07:06 PM
0 votes
2 answers
8195 views
Why did my service become masked?
I've provisioned a bunch of RPis with a systemd service that runs an instance of chromium-browser in kiosk mode, but on a few seemingly random devices it doesn't run. I checked the status just by trying to enable it and I get ``` $ sudo systemctl enable kiosk.service Failed to enable unit: Unit file...
I've provisioned a bunch of RPis with a systemd service that runs an instance of chromium-browser in kiosk mode, but on a few seemingly random devices it doesn't run. I checked the status just by trying to enable it and I get
$ sudo systemctl enable kiosk.service
Failed to enable unit: Unit file /lib/systemd/system/kiosk.service is masked.
I looked up what it means for it to become "masked" in order to understand how this happened, and responses simply state that "the units are linked to /dev/null". Okay, but *why* did that happen to my service? ~~systemctl unmask kiosk.service will unmask my service but~~ (scratch that, see edit below) I'd like to make sure it doesn't continue to happen. Here is the actual "kiosk.service" contents if relevant:
[Unit]
Description=Chromium Kiosk
Wants=graphical.target
After=graphical.target

[Service]
ExecStartPre=/bin/sleep 20
Environment=DISPLAY=:0.0
Environment=XAUTHORITY=/home/pi/.Xauthority
Type=simple
ExecStart=/bin/bash /home/pi/kiosk.sh
Restart=on-abort
User=pi
Group=pi

[Install]
WantedBy=graphical.target
**EDIT:** Actually sudo systemctl unmask kiosk.service doesn't seem to do anything. When I do that then sudo systemctl enable kiosk.service it returns the same complaint that it's masked. **EDIT2:** So instead of succesfully being able to unmask I simply deleted lib/systemd/system/kiosk.service and re-subscribed it as a service, now it appears to remain enabled. Still have no idea why it was masked to begin with.
A__ (101 rep)
Sep 20, 2023, 05:41 PM • Last activity: Jun 14, 2025, 05:09 AM
Showing page 1 of 20 total questions