105 votes
Accepted

What is the difference between service and systemctl?

service is an "high-level" command used for starting and stopping services in different unixes and linuxes. Depending on the "lower-level" service manager, service redirects on different binaries. ...
shodanshok's user avatar
  • 50.6k
91 votes

"reboot" or "shutdown -r now": what restart command is safer?

Shutdown is preferable because it allows you to specify the reason for the drastic action -- something you should always do. The message will be recorded in the log(s) for posterity. For example: ...
Mikhail T.'s user avatar
  • 2,377
62 votes
Accepted

Configuring Systemd Service to run with root access

tell systemd to run the service with sudo? sudo has nothing to with it. Typically you instruct systemd to run a service as a specific user/group with a User= and Group= directive in the [Service] ...
HBruijn's user avatar
  • 80.3k
60 votes
Accepted

Disable all services, except ssh

This sounds a lot like runlevels, replaced with targets in Systemd. So, instead of writing a script that starts and stop a list of services, you could create a new maintenance.target containing only ...
Esa Jokinen's user avatar
  • 49.8k
58 votes
Accepted

"reboot" or "shutdown -r now": what restart command is safer?

For Red Hat systems, there is no functional difference between reboot and shutdown -r now. Do whatever is easier for you.
ewwhite's user avatar
  • 198k
47 votes
Accepted

Find out who disabled a Windows service

When the start type of a service is changed, an event is recorded in the system event log , with id 7040 and source Service Control Manager. The user that performed the operation is displayed in the ...
JFL's user avatar
  • 2,028
42 votes

Configuring Systemd Service to run with root access

To clear, systemd system services run as root by default, but there is still a difference between the default behavior and running a system service with User=root. As documented in Environment ...
Mark Stosberg's user avatar
39 votes

How to automatically restart a service on failure in Linux

Only answering the service restart part. I came across Monit as well, but on CentOS 7 systemd takes care of all that for you. You just need to add these two lines to the .service file (if they're not ...
Nagev's user avatar
  • 610
34 votes

get notification when systemd-monitored service enters failed state

Just my way to notify : /etc/systemd/system/[email protected] [Unit] Description=Sent email [Service] Type=oneshot ExecStart=/usr/bin/bash -c '/usr/bin/systemctl status %i | /usr/bin/mailx -...
ceinmart's user avatar
  • 507
30 votes
Accepted

Configure buggy systemd service to terminate via SIGKILL

systemd already supports this out of the box, and it is enabled by default. The only thing you might want to customize is the timeout, which you can do with TimeoutStopSec=. For example: [Service] ...
Michael Hampton's user avatar
30 votes
Accepted

systemd service with multiple After

The unit file you posted looks fine. But the unit as you defined it here has no strict dependencies, only weak (Wants= instead of Requires=). That means if network.target is not there or if it fails ...
nix's user avatar
  • 476
27 votes

How to start/stop/restart launchd services from the command line?

To restart a service, you can use the launchctl kickstart command, together with the -k option. For example, to restart apache, you can use sudo launchctl kickstart -k system/org.apache.httpd This ...
jochen's user avatar
  • 371
24 votes

What is the difference between service and systemctl?

systemctl is basically a more powerful version of service. With service you can only do commands related to the service (i.e. status, reload, restart) whereas with systemctl you can use more advanced ...
SamCyanide's user avatar
23 votes
Accepted

Cannot change Windows Service properties: Error 87: The parameter is incorrect

I stumbled upon the same issue when trying to disable MessagingService_48ab2. The solution for it was to look for the service in the registry. Press start button on your keyboard, type regedit, ...
askepott's user avatar
  • 346
18 votes

How to start/stop/restart launchd services from the command line?

You could simply do sudo launchctl stop com.openssh.sshd If you don't known the full service name, you can do sudo launchctl list If you still don't find the service you expected, try to run ...
Dmitriy Apollonin's user avatar
17 votes

Can't start mysql service

Run mysqld --help and check, if it reports any problems with config Check logs in /var/log/mysql Try runnig it directly and check errors: mkdir /var/run/mysqld/ chown mysql: /var/run/mysqld/ mysqld ...
Selivanov Pavel's user avatar
17 votes

"reboot" or "shutdown -r now": what restart command is safer?

Using reboot is safer. Using reboot your intent is clear and there is no way to mistype it for something else like shutdown -t now which could leads to a few headache if you are using on a remote ...
Antzi's user avatar
  • 303
17 votes
Accepted

varnish daemon not listening on configured port

You need to change the varnish start parameters in the systemd service definition as well. You could edit the line starting with ExecStart in the service defintion file: sudo vi /lib/systemd/system/...
Gerald Schneider's user avatar
14 votes

Find out who disabled a Windows service

In Event Viewer, look in the "Windows Logs"->"System" event log, and filter for Source "Service Control Manager" and Event ID 7040. Find the event saying "The start type of the service was changed ...
Pak's user avatar
  • 919
13 votes

"reboot" or "shutdown -r now": what restart command is safer?

If you take a look, in RHEL 7 both /sbin/shutdown and /sbin/reboot are actually just symlinks to systemd's systemctl command. So, use whatever you want. No functional difference as ewwhite told, not ...
Janne Pikkarainen's user avatar
12 votes
Accepted

Non standard ssh port: should I edit /etc/services?

I don't think it makes sense to edit /etc/services in such a case. The world will not change ssh ports with you, and all programs that look up service names to port numbers on your machine would get ...
Håkan Lindqvist's user avatar
12 votes
Accepted

How to configure a service auto-restart after failure with PowerShell

There is currently no native PowerShell cmdlet to manage the service recovery. However, to auto-restart a service when it fails you can use SC. (In a PowerShell prompt you must precede it with & ...
Luke's user avatar
  • 479
12 votes
Accepted

What killed my tomcat service and how can I restart it automatically?

Unless a cruel sysadmin gave it kill -9, I would suspect that Linux kernel's OOM (Out of memory killer) did kill the process. Check if dmesg hints towards that direction. If so, inspect if your server ...
Janne Pikkarainen's user avatar
11 votes
Accepted

How to use variables in a systemd service file?

The directive is Environment, not EnvironmentVariable. Environment= Sets environment variables for executed processes. Takes a space-separated list of variable assignments. This option may be ...
Esa Jokinen's user avatar
  • 49.8k
10 votes

Make systemd user service depend on system target

I was having the same problem, with a userland backup script that needs access to the internet. I solved it by adding ~/.config/systemd/user/wait-for-network.service that just pings google.com until ...
Thomas's user avatar
  • 811
10 votes

Nginx hangs using "service nginx start"

I'm having the same issue with Ubuntu 16.04, systemd and NginX 1.10.1 from source. I was using the default nginx.service file: https://www.nginx.com/resources/wiki/start/topics/examples/systemd/ The ...
Maxim's user avatar
  • 201
10 votes

What is the difference between service and systemctl?

systemctl is the main utility to control daemons/services in systemd, while the service command is the traditional utility in SysVinit world. One of systemd's features is to be compatible with ...
maioman's user avatar
  • 209
10 votes
Accepted

Apache 2.4 is unkillable and can't be stopped on Windows Server

OK, so I think I was on the right track. After searching on the Web about the recently installed updates, the KB4338818 is the one causing problems. This is happening for other softwares, like ...
SiZiOUS's user avatar
  • 311
9 votes

Non standard ssh port: should I edit /etc/services?

The file /etc/services contains the IANA assigned port numbers and there is not a single technical requirement to modify that file to be able to you run your services on a non-standard port. When you ...
HBruijn's user avatar
  • 80.3k
9 votes
Accepted

How do I specify NetworkService or LocalService for a Windows Service on a Domain Controller?

Based on your final screenshot, you left out the space in the account name. Try Local Service instead. If that doesn't work, you can do it on the command line as shown here, I would write this as: ...
Harry Johnston's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible