Sponsored Content
Top Forums Shell Programming and Scripting How to integrate all the systemctl commands into a shell script to verify any daemon/agent service? Post 303016809 by Mannu2525 on Friday 4th of May 2018 10:38:34 PM
Old 05-04-2018
How to integrate all the systemctl commands into a shell script to verify any daemon/agent service?

Hi,

Can we integrate all the systemctl command into a shell script to verify any service with all the options of systemctl if service integrate with the operating system service management tools to deliver their functionality.

Code:
sudo systemctl start <service_name>
sudo systemctl stop <service_name> 
sudo systemctl restart <service_name> 
sudo systemctl reload <service_name>
sudo systemctl status <service_name> 
sudo systemctl condrestart <service_name> 
sudo systemctl list-unit-files --type=service  <service_name> 
sudo systemctl enable <service_name> 
sudo systemctl disable <service_name> 
sudo systemctl is-enabled <service_name> 
sudo systemctl list-dependencies graphical.target <service_name>
sudo ls /etc/systemd/system/*.wants/ <service_name>
sudo systemctl daemon-reload <service_name>

I was thinking just to have a clear ordering and way they can run in sequence (Not much aware about the sequence and how we club them into the script to make it a functional verification script) just to verify the entire commands for the service. Please assist.

---------- Post updated 05-04-18 at 09:38 PM ---------- Previous update was 05-03-18 at 11:11 PM ----------

Any suggestions folks!
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script as a daemon

hi, can i run a shell script as a daemon ? the shell script looks like this : can this be run as a service ?: thanks regards shann (1 Reply)
Discussion started by: massoo
1 Replies

2. UNIX and Linux Applications

Integrate PHP + Unix commands

Hi I am using fedora 4, its only for desktop usage. its in gui mode. the system is always on and in login screen. whenever a particular user logins in, aphp page inside the system should run. The user should not be able to view the desktop. The user has the info in the php webpage to work... (1 Reply)
Discussion started by: karthikn7974
1 Replies

3. Red Hat

difference between restarting a daemon and a service

Hi, Can you please clear me the difference between restarting the daemon and the service. To be more clear, /etc/init.d/mysqld restart and /etc/init.d/mysqld restart What is the difference on this both two?..... (4 Replies)
Discussion started by: gsiva
4 Replies

4. Red Hat

Can't start NTOP service/daemon

I have installed version of ntop 4.0.3 by guide. But I can't start ntop daemon/service. I didn't find a service file for starting. During the installation there was no problem only want to RRDTool so I installed that. Now there is no necessary package required. I didn't find in /etc/init.d/... (9 Replies)
Discussion started by: getrue
9 Replies

5. AIX

Need help on patrol agent service in AIX

Hi, Anyone know what is patrol agent service in aix If know please tell me the command to check the same. (4 Replies)
Discussion started by: sumanthupar
4 Replies

6. Web Development

Help to integrate Shell script with PHP

I have a shell script which takes user name and server name from the user and check the authentication type on that server like LDAP or VAS or local. It also provides various other info also such as owner of the ID and etc. I need this script to work on the browser where user can directly input... (2 Replies)
Discussion started by: Bhuwan Nazkani
2 Replies

7. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

8. Shell Programming and Scripting

Shell script verify connection to Oracle if not successful

i have a script that connects to the oracle database and executes the query statements. it works fine and i would like to add some message to check if the connection to oracle is not successful. basically this is the code snippet: #!/bin/sh ... ... ... sqlplus -s username/password@dbName... (2 Replies)
Discussion started by: wtolentino
2 Replies
service(8)						      System Manager's Manual							service(8)

NAME
service - run a System V init script SYNOPSIS
service SCRIPT COMMAND [OPTIONS] service --status-all service --help | -h | --version DESCRIPTION
service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /. The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT. The supported values of COMMAND depend on the invoked script, service passes COMMAND and OPTIONS it to the init script unmodified. All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. service --status-all runs all init scripts, in alphabetical order, with the status command. If the init script file does not exist, the script tries to use legacy actions. If there is no suitable legacy action found and COMMAND is one of actions specified in LSB Core Specification, input is redirected to the systemctl. Otherwise the command fails with return code 2. FILES
/etc/init.d The directory containing System V init scripts. ENVIRONMENT
LANG, TERM The only environment variables passed to the init scripts. SEE ALSO
chkconfig(8), ntsysv(8), systemd(1), systemctl(8), systemd.service(5) Jan 2006 service(8)
All times are GMT -4. The time now is 05:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy