WTF is a service or a daemon?
Daemons are a kind of non-interactive process that runs in the background. They basically are detached from the keyboard and display.
Services also do not need a terminal. They run in the background to provide some service like apache.
The service here is the command’s target. Basically, it is the service you want to manage using systemctl.| command | What it does? |
|---|---|
| status | Returns the status of the service |
| start | Attempts to start the service |
| stop | Stops the service |
| restart | Restarts the service |
| reload | Reloads the service’s configuration. This applies the new configuration. |
| enable | Enables autostart on boot |
| disable | Disables autostart on boot |
Service’s status
Now, Let’s see the different statuses that every service could have.
| Status Name | Status Description |
|---|---|
| loaded | The service’s configuration files have been loaded successfully |
| active | The service is running or waiting for a certain event to run. |
| inactive | The service is not currently running |
| enabled | The service will start at boot |
| disabled | The service will not start at boot |
For instance : RHEL 7.x , 8.x
systemctl enable crond
systemctl start/stop/restart crond
systemctl status crond
crontab -e ## For current logged user
crontab -e -u <user> ## For particular user
tail -f /var/log/cron ## To check log
systemctl start/stop/restart crond
systemctl status crond
crontab -e ## For current logged user
crontab -e -u <user> ## For particular user
tail -f /var/log/cron ## To check log
Sample Script for Splunk services restart restart:
#!/bin/sh
cd /opt/splunk/bin
status=`./splunk status`
abc="splunkd is running"
if [ "${status:0:18}" == "$abc" ]
#!/bin/sh
cd /opt/splunk/bin
status=`./splunk status`
abc="splunkd is running"
if [ "${status:0:18}" == "$abc" ]
then
echo "good"
else
cd /opt/splunk/bin
./splunk restart
./splunk restart
fi
Comments