[Systemd] - How to tell if a service is running in a bash script

I need a bash script to query systemd (systemctl or systemd or?) to see if a given service is running. Is there a way to do it talking to systemd directly, not by looking for a pid file or seeing if a process is running? Thank you.

Good point.
I'd say that, in the case of "RemainAfterExit=yes" services, it's not really black and white. The effects of the service are active, even if the service itself has exited, but it's up to the user to decide whether or not that's "running" in their opinion.

Similar Messages

  • How to tell what packages have recently run

    Occasionally, after start up, I'll see something that looks like a package that quickly runs.  I have no idea where to look for information to figure out what ran.  I've ran searches trying to find out how to tell what packages have recently run but have not found anything useful.  If anyone knows or has any ideas on what I can do to figure that out, I'd love the help.

    You are welcome. Based on my experiences, the only time I look at Console is when something is not working. You could get overly engrossed trying to figure out what everything means.

  • HOW DO I  RUN A UNIX BASH SCRIPT FROM JAVA??

    HI. Here's a tricky little problem i have. There's a unix bash script that has some commands in it, that manipulate a file. It appends a certain string variable to a file called users. The users file is an ordinary text file.
    I know this script to work perfectly, when i invoke it like this directyl from the command line: ./addusers.sh
    or even: bash /downloads/selinux/policy/addusers.sh
    Now, i have a java program, and its meant to just execute that script. It doesnt throw any Exceptions at runtime. But when i look at the users file, and expect it to have an extra line that was the string variable, the file is UNTOUCHED!
    Again, direct command line invocation works, but not from java. Here's what my invocation from java looks like:
    Process p = Runtime.getRunTime().exec("bash downloads/selinux/policy/addusers.sh");
    The strange thing is, i tried a different bash command. I tried:
    Process p = Runtime.getRunTime().exec("mkdir /temporary");
    and this worked!
    so why not the other one??
    I cant figure it out.

    You say:
    bash /downloads/selinux/policy/addusers.sh
    And you say in Java:
    Process p = Runtime.getRunTime().exec("bash
    downloads/selinux/policy/addusers.sh");
    As if a leading / would be missing from the Java
    version...nyix says:>
    ...OK sorry about that. i DO have a / in front of the downloads.... section in the java method. So its:
    Process p = Runtime.getRunTime().
    exec("bash /downloads/selinux/policy/addusers.sh");
    HELP please?

  • How do I restart X from the console or from bash script?

    I have searched with google, but can't find any answers not involving gdm or xdm. I need this because I'm writing a simple script that compiles and installs dwm and then restarts x.
    Thanks.

    Ashren wrote:
    lilsirecho, no it does nothing.
    buttons, sudo kill 'pidof X' && startx did work with xdm enabled (I still had to login again, though). The reason I don't use respawn is that I don't like display managers. Is there any way to circumvent them and still have the respawn feature? I want to restart dwm without typing in anything, besides the name of my script.
    Thanks..
    Absolutely.
    Relevant parts of /etc/inittab:
    id:5:initdefault:
    x:5:respawn:/bin/su buttons -l -c "/bin/bash --login -c startx >/dev/null 2>/home/buttons/.xsession-errors"
    "buttons" is of course my login name, and I prefer to have my errors go to a logfile in my home directory, which many display managers do by default.  Or at least GDM.

  • How to schedule a service to run before network goes down

    Hi
    I wrote a new smf service and added it to the repository.
    When running with "stop" (when the system goes down) it sends an alert to another machine.
    My question is :
    How can I schedule that service to run just before network services go down?
    another question, how can I schedule another service to run just BEFORE system is getting down?
    Many Thanks
    --me2unix                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Dependencies appear to be really written and tested on the boot side, but they should work properly going down as well.
    My first assumption is that you'd make a dependency on the network for your service. So it should be started after the network starts, and will wait for your service to quit before trying to shut down the network.
    Now this would only apply to normal shutdowns. Also, there are mulitple services on the box that have network affects. You may need to read through several to understand their purpose and interaction to pick the correct one for your use. Probably the milestone/network will be the best choice.
    Darren

  • Could any one tell me that How can i create the service User ie j2ee SID

    hi all,
    In the implementation of SPNego Authentication schem in my portal system.
    i want to create the service user ie .j2ee-<SID>.
    <b>could any one tell me that How can i create the service User ie j2ee-<SID> in my visual administrator??</b>.
    any help will be highly Appretiated .
    thanks and regards.
    vinit soni.

    Vineet,
    the user management tab opens in Read Only mode - thats why the button is coming as disabled. There is a button for switching into Edit mode - it looks like a pen / pencil on the top bar. Click on that - your "Create User" button would be enabled.
    Also regarding creation of Service User via code level you can see <a href="https://www.sdn.sap.com/irj/sdn/thread?messageID=1057074">THIS</a> thread. And <a href="http://HERE">http://help.sap.com/saphelp_nw04/helpdata/en/f9/e3162ec55f4df6922d161f3785012a/frameset.htm</a>HERE[/url] is the SAP Help documentation on required permission settings.
    Regards,
    Shubhadip
    Message was edited by:
            Shubhadip Ghosh
    Message was edited by:
            Shubhadip Ghosh

  • How does one tell if the J2EE services are running with Unlimited

    How does one tell if the J2EE services are running with Unlimited
    security? We have applied the export Policy to the server but we do notsee any reference to it running with it. .we apply the Service packs SAP now upgrades that JAVA as well . Do that process treat the JAVA
    lib/security area correctly.

    Just out of curiosity... Is there something you do
    like about Mac/Apple?
    To answer your question: no, not really. However, the points that I made here were about Safari and accompanying utilities, not about Apple in general.
    If it makes you feel any better, I am just as, or even more, critical of Micro$oft as the occasions arise...Windoze Vista is the most recent occasion and has given sufficient reasons and opportunities to vent my spleen that I actually have eased up on Apple, politicians, nut-case religious extremists, cell phone owners, and the Department of Homeland Paranioa, etc., due to an exhaustion of creative energy.

  • How to tell SAFARI to select especific mail service

    Does any one know, how to tell SAFARI to use for example, YAHOO web mail serivice instead of MAC MAIL, when selecting the option MAIL LINK TO THIS PAGE.
    Tks in advanced from México

    Ralphjh,
    An Automator workflow can save the page in a web archive format:
    First download the Save Safari Web Archive workflow.
    I would add two additional actions at the beginning of the workflow, each from Automator's Safari library, so that your final workflow would look like this:
    1) *Get Specified URLs* -- Deselect or use the minus sign to remove the default www.apple.com address. Open your puzzle page in Safari, make it frontmost, and click on the Current Safari Page button.
    2) *Display Webpages*
    3) *Run AppleScript* -- No need to modify the existing script.
    4) *Get Selected Finder Items*
    5) *Move Finder Items* -- The desktop is default.
    Save the Workflow as File Format: application, and add it to your Login Items.
    It all may be for naught however. I suspect that upon your return from vacation, you'll be disappointed to find that opening any one of the saved files will only result in opening the current day's puzzle. For example, on Tuesday April 29th, the puzzle linked from the URL you posted opened the puzzle for +that day,+ Puzzle Number 760. A quick look at the 30 Day Killer archive (scroll down the page) reveals that each day's puzzle has its own URL. The actual URL for Puzzle Number 760 is:
    http://www.sudoku.org.uk/DailyKiller.asp?day=29/04/2008
    You'll notice that the URLs for the individual days' puzzles in the Killer Archive differ only in the dates appended to them. You would likely need to find a way to incorporate that pattern into an AppleScript -- correlating the current date to the updated URL.
    Regards, Andrew99

  • How to access .asmx Web Service using JAVA? Newbie

    Hello Experts,
    Currently, I have a project where in I have to access a ,NET web service. It is made of C#. I just want to ask how will I start the accessing process? I made this simple equation on how my project is.
    Java Project + C#.Net Web Service = Integration
    1. Do i need to create a Web Service too for the Java Project? If yes, What are the necessary tools needed for the creation of this Java Web Service?
    2. The .NET Web Service is available online. (It is made by other people).
    3. Based on the equation, what is the equivalent technology for the + sign?
    4. Can you site a concrete example for accessing a web service?
    5. I'm new here. Totally I have no idea where to start.
    6. Thank you experts.
    Edited by: Benedict.Aluan on 05 30, 08 1:38 PM
    Edited by: Benedict.Aluan on 05 30, 08 1:39 PM

    Hello
    Thanks a lot for your help ...
    I am developing simple J2EE based web service client using IBM WSAD 5.1. I have used the following code to call .asmx web service in Java
    String url = "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl";
         String namespace = "http://tempuri.org/";
         name = request.getParameter("txtName");
         try
              System.out.println("In Internet Service");
              ServiceFactory factory = ServiceFactory.newInstance();
              Service serv = factory.createService(new URL(url),new QName(namespace,"TempConvert"));
              System.out.println("Got Service......");
              Call obj = (Call)serv.createCall();
              System.out.println("Got Call......");
              obj.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY,"");
              obj.setProperty(Call.OPERATION_STYLE_PROPERTY,"wrapped");
              obj.setTargetEndpointAddress(url);
              obj.setPortTypeName(new QName(namespace,"TempConvertSoap"));
              obj.setOperationName(new QName(namespace,"FahrenheitToCelsius"));
              obj.addParameter("param1",XMLType.XSD_STRING,String.class,ParameterMode.IN);
              obj.setReturnType(XMLType.XSD_STRING);
              System.out.println("Parameters Set.....");
              Object[] params = new Object[]{name};
              k = (String)obj.invoke(params);
              System.out.println("Result: "+k);
         catch(Exception e)
            System.out.println("Exception is : "+e);
        }But this code is throwing exception that
    Invalid Address "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl"I have also tried this URL with Java Proxy. But it showing the same error.
    Plz can u tell me how to access .asmx web service ?
    Waiting 4 reply.

  • How to use the same services-config for the local and remote servers.

    My flex project works fine using the below but when I upload my flash file to the server I doesn't work, all the relative paths and files are the same execpt the remote one is a linux server.
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
        <services>
            <service id="amfphp-flashremoting-service"
                class="flex.messaging.services.RemotingService"
                messageTypes="flex.messaging.messages.RemotingMessage">
                <destination id="amfphp">
                    <channels>
                        <channel ref="my-amfphp"/>
                    </channels>
                    <properties>
                        <source>*</source>
                    </properties>
                </destination>
            </service>
        </services>
        <channels>
        <channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
            <endpoint uri="http://localhost/domainn.org/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>
        </channels>
    </services-config>
    I think the problem  is the line
            <endpoint uri="http://localhost/domainn.org/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
    but I'm not sure how to use the same services-config for the local and remote servers.

    paul.williams wrote:
    You are confusing "served from a web-server" with "compiled on a web-server". Served from a web-server means you are downloading a file from the web-server, it does not necessarily mean that the files has been generated / compiled on the server.
    The server.name and server.port tokens are replaced at runtime (ie. on the client when the swf has been downloaded and is running) not compile time (ie. while mxmlc / ant / wet-tier compiler is running). You do not need to compile on the server to take advantage of this.
    Hi Paul,
    In Flex, there is feature that lets developer to put all service-config.xml file configuration information into swf file. with
    -services=path/to/services-config.xml
    IF
    services-config.xml
    have tokens in it and user have not specified additional
    -context-root
    and this swf file is not served from web-app-server (like tomcat for example) than it will not work,
    Flash player have no possible way to replace token values of service-config.xml file durring runtime if that service-config.xml file have been baked into swf file during compilation,
    for example during development you can launch your swf file from your browser with file// protocol and still be able to access blazeDS services if
    -services=path/to/services-config.xml
    have been specified durring compilation.
    I dont know any better way to exmplain this, but in summary there is two places that you can tell swf  about service confogiration,
    1) pass -services=path/to/services-config.xml  parameter to compiler this way you tell swf file up front about all that good stuff,
    or 2) you put that file on the webserver( in this case, yes you should have replacement tokens in that file) and they will be repaced at runtime .

  • How to tell N6.5 DHCP to use a W2k8 for PXE?

    Hello,
    could anyone give me a hint, how to tell my netware DHCP to use a Windows Server 2008 R2 running Acronis with PXE Server?
    Actual Situation:
    Netware 6.5 Sp8 Server with ZENWORKS in Cluster mode
    Netware DHCP Server
    ZEN7 SP1 Imaging
    --> works fine so far, and no problem in other subnets, IP-helper are configured in the switches
    New Situation:
    Netware 6.5 Sp8 Server with ZENWORKS in Cluster mode
    Netware DHCP Server
    Windows Server 2008 R2 running Acronis Snap Deploy with PXE-Server - in future may be a clean Windows Deployment service without Acronis
    --> that would be nice :)
    I found serveral ini-files (dts.ini, pdhcp.ini, tftp.ini) where I configured the new IP-Address of the W2k8 PXE Server.
    Now:
    The Client gets its correct IP-Address from Netware DHCP
    but after that the following messages:
    Auto-select:
    ZENworks Boot
    Boot Server IP: --.--.--.-- (the correct one configured in the ini-files!)
    TFTP.
    PXE-T02:
    PXE-E3C: TFTP Error - Access Violation
    PXE-M0F: Exiting Intel Boot Agent
    Any ideas?
    Thanks a lot.

    Originally Posted by magic31
    You don't have to configure anything specifically in DHCP to work with PXE. Possibly just unconfigure an option that was set for the previos setup; One thing to check (and remove) is option 60 for the PXE Client option, if this is configured with the DHCP subnet options. This option should only be set if both DHCP and PXE services are on the same server (as is probably the case in your situation as I'm guessing both DHCP as also PXE get loaded in the same cluster resource script).
    For subnets serviced outside of the subnet your DHCP server is running in, you will need to configure multiple ip helpers: one that points to the DHCP server and one points to the PXE server so those requests on other subnets get serviced correctly.
    To get things running it's probably easier to try to get this to work on the subnet your DHCP and PXE server are running in (so you are not also having to deal with the ip helper setup just yet). If that works, then expand you configuration to different subnets & ip helpers.
    Hope that helps,
    Willem
    As a ps and for clarification, don't load the PDHCP on any of the NetWare servers... just have the PXE PDHCP service running on the Windows server.
    The PDHCP/PXE service for ZenWorks won't understand/work with the Arconis one and visa versa.
    -Willem

  • Fan how to tell if it works? What test can I do? G62-a17SA

    G62-a17SA
    HP G62-a17SA
    Windows 7 64 bit
    How to tell if the fan works? it works when Laptop powered up, but no other times.
    I've had it less than a year, and customer services, wont fix it unless I mail the receipt, which I cant find. i called the next day and said I will pay for it to be looked at, and replaced if needed. The price was £223.94. Which is 51% of the price I paid for the laptop originally, so I left it.
    I need to know if my laptop is save to use. It can get hot, I'm worried it could start a fire. The fan only comes on when I boot the laptop up, no other times. What software can I use to tests to see if it functions properly? then I know if i will have to pay to send it away. (not a dust or venting problem) also its a instant sudden one
    Please help
    Oliver
    This question was solved.
    View Solution.

    HP G62-a17SA
    Windows 7 64 bit
    How to tell if the fan works? it works when Laptop powered up, but no other times.
    I've had it less than a year, and customer services, wont fix it unless I mail the receipt, which I cant find. i called the next day and said I will pay for it to be looked at, and replaced if needed. The price was £223.94. Which is 51% of the price I paid for the laptop originally, so I left it.
    I need to know if my laptop is save to use. It can get hot, I'm worried it could start a fire. The fan only comes on when I boot the laptop up, no other times. What software can I use to tests to see if it functions properly? then I know if i will have to pay to send it away. (it's not dust or venting problems)
    Please help
    Oliver

  • [Forum FAQ] How to tell if the DAC port is automatically changed or not

    Introduction
    Per Books Online:
    http://msdn.microsoft.com/en-us/library/ms189595.aspx
    SQL Server listens for the DAC on TCP port 1434 if available or a TCP port dynamically assigned upon Database Engine startup.
    Also, we can go to the following registry to specify the DAC port number manually:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\AdminConnection\Tcp
    The error log contains the port number the DAC is listening on. Besides looking at the error log, how to find which port is used by DAC connection and how to tell if the DAC port is manually set by us or assigned automatically by SQL Server?
    Solution
    The following query can be used to check if there is an existing DAC connection and it also give us the port number used by dedicated admin connection.
    SELECT name,local_tcp_port FROM sys.dm_exec_connections ec
    join sys.endpoints e
    on (ec.endpoint_id=e.endpoint_id)
    WHERE e.name='Dedicated Admin Connection'
    Here is the scenario to test if the DAC port is automatically changed or not.
    There are two instances are running on one server. I specified the same DAC port number 5555 for the two SQL Server instances by modifying the registry
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\AdminConnection\Tcp
    Opened the DAC connection to instance 1. Executed the above query, it returns the result:
    name                                                  
    local_tcp_port
    Dedicated Admin Connection               5555
    Then, opened a DAC connection to instance 2. It throw out the following error message:
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Client unable to establish connection because an error was encountered during handshakes before login.
    Common causes include client attempting to connect to an unsupported version of SQL Server, server too busy to accept new connections or a resource limitation (memory or maximum allowed connections) on the server..
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : TCP Provider: An established connection was aborted by the software in your host machine..
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Client unable to establish connection.
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Client unable to establish connection due to prelogin failure.
    The above error message was thrown out because the DAC port number 5555 was not available for instance 2 which was occupying by instance 1. After restarting the SQL Server engine service of instance 2, if checking in the registry, you would see a new DAC port
    number has been assigned to the second instance.
    Then, the DAC connection to instance 2 succeed this time and executed the above query, it returned the same port number which is same as the one in the registry key and the port number was assigned automatically.
    DAC port will not change even SQL Server service is restarted only if the TCP port is available.
    More Information
    http://msdn.microsoft.com/en-us/library/ms189595.aspx
    Applies to
    SQL Server 2012
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    I tested your script after
    establishing a DAC connection from SSMS 2014. It worked as described. Thank you.
    SELECT name,local_tcp_port FROM sys.dm_exec_connections ec
    join sys.endpoints e
    on (ec.endpoint_id=e.endpoint_id)
    WHERE e.name='Dedicated Admin Connection'
    name local_tcp_port
    Dedicated Admin Connection 1434
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How can i enable ldap service in my system?

    How can i enable ldap service in my system?while running my prgram i am getting an error connection refused why?

    hi
    thanks for u r kind attention.
    i want execute simple jndi program on WinXPwhich uses ldap sevices.
    in the JNDI Tutorial it is given that u can make use of ldap service provided by JDK.i am using a latest version of jdk.
    where the programs for enabling ldap sevice is located in JDk ?how can i enable it?
    and also i have down latest releases of openLDAP software?if the earlier is not possible u tell me how to configure openLDAP?
    thanks in advance

  • How to consume/access web services in forefront identity manager 2010 r2

    Hi,
    I have one web service  in c# for authentication  so i want to integrate this web service in my FIM 2010 R2.I want to ask one more question how to consume/access web service of FIM 2010 R2,so please tell me how is it possible in FIM 2010 R2 and
    anybody have any example for consuming/accessing web service step by step in FIM 2010 R2.
    Regards
    Anil Kumar

    Here is some C# code that accesses FIM resource attributes from the web services via the FIM 2010 Resource Management Client which I mentioned in an earlier post:
    using System;
    using System.Collections.Generic;
    using Microsoft.ResourceManagement.Client;
    using Microsoft.ResourceManagement.ObjectModel;
    namespace MyTest
    public partial class ResourceAttribute
    public ResourceAttribute()
    public string GetTypeAndDisplayName(string objectID)
    String ReturnValue = String.Empty;
    using (Microsoft.ResourceManagement.Client.DefaultClient client = new DefaultClient())
    client.ClientCredential = CredentialCache.DefaultNetworkCredentials;
    client.RefreshSchema();
    string query = String.Format("/*[ObjectId={0}]", objectID);
    foreach (RmResource res in client.Enumerate(query))
    String displayName = res.DisplayName;
    String objectType = res.ObjectType;
    ReturnValue = displayName + " (" + objectType + ")";
    break;
    return ReturnValue;
    You would just need to define your bindings and endpoints in your web.config. This method will return the DisplayName and ObjectType for the resource with the ObjectId matching the objectID argument. If you need more information, please provide more specifics
    for what you are trying to accomplish.
    There are many code examples for this library on its CodePlex home:
    http://fim2010client.codeplex.com/

Maybe you are looking for

  • Newly installed ID5 freezes while trying to open...help!

    I just installed CS5 Design Premium and the ID5 gets stuck trying to open, I then need to force quit. I seems to be looking for something. I can open pre-existing files but the same thing happens when I try to close the file, then I need to force qui

  • Reduce image size and print it out?

    I scanned an image (coloring on a postcard). This size is too big to fit into a 'album' picture in MS Picture It! All I want to do is REDUCE the image and save it so that it will fit into the computer photo album I'm creating. I've tried Image/Resize

  • So AEBS doesn't work with my OS?

    I just got back from the Apple store with a brand new 802.11n router which the sales rep assured me will work on my older "g" laptop. What he didn't tell me is that it is not compatible with OS 10.3.9 which I discovered AFTER opening the box and read

  • To Reopen the Completed Status Global outline agreements

    Hi, We have got some Global Outline Agreemtns with 'completed' status by the user. We want to reopen it for additional processing,but the change icon in the global outline agreement is greyed out. Could anybody tell me how to reopen the 'completed' s

  • .mdf mysql database to allow to be accessed in LAN

    i just finished my application, i did my application in visual studio 2013 and created my database in sql which turned out to be an .mdf file. i was wondering, how can i make people in my network access the database. i installed Microsoft Sql server