I am currently using RHEL 7.0 for our project. I have an embeded application which I want to run on boot up. I have an exe file for the same. I have tried using the systemctl command but it has not helped. I also tried editing the inittab file but that didn't help too. I also tried adding a rc.local file and edit the rc.d to add the execution of rc.local but it said that the file cannot be modified. (I was in sudo mode when I tried this).

I wish to start the application on boot up without asking a user to login. Also where should we keep our exe in filesystem so that it will be detected at startup. Can someone please guide on how can I achieve this ?

  • 1
    Can't write a full answer but you can write a unit file for rc.local or just the executable you're wanting to start. – Bratchley Dec 4 '14 at 12:57

You can use the following unit file as a template:

Description=A Test Service That Prints the date
ExecStart=/usr/bin/bash -c "/usr/bin/date >> /now.txt" $MYSERVICE_ARGS

Save it in /etc/systemd/system/ with a .service file extension (for example /etc/systemd/system/myservice.service)

Any environment variables that are needed by your application can be placed in /etc/sysconfig/myservice, including the creation of a variable to hold your command line options:


(If you use a variable for the command line options, then add the variable to your command in ExecStart as follows: ExecStart=/usr/local/bin/myservice $MYSERVICE_ARGS)

Test it with:

# systemctl start myservice

You should now have a file /now.txt that has the date/time appended every time this is run.

Enable it to start at boot with:

# systemctl enable myservice

It should now start automatically after networking comes up.

Alter the ExecStart line to run your application. Remember that systemd doesn't run ExecStart in a shell therefore if you need redirection, for example, then you'll need to run bash -c as per the example. Also, there will not be a $PATH variable, therefore use full paths. The application will be run as user root.

There are far more options that you can use - read the man page. Also, browse your system's unit files in /usr/lib/systemd/system.

  • Thanks for the reply. ExecStart should have the path of my executable or a shellscript file? – Sid411 Dec 5 '14 at 9:36
  • @Sid411 - Whichever one works for you. If you look at the examples in /usr/lib/ you'll see executables being called. If your application starts with just a command line invocation (maybe with some options) then that will be fine. However, it may be more complex that that, so you may need a script to start it. – garethTheRed Dec 5 '14 at 9:52
  • I have done the same thing. Gave the path to my executable.it is still not working. Its still asking for login and if I check the status of the service it gives me the following: Redirecting to /bin/systemctl status TestBOSService.service TestBOSService.service - A Test Service Loaded: loaded (/usr/lib/systemd/system/TestBOSService.service; enabled) Active: failed (Result: core-dump) since Fri, 05 Dec 2014 15:52:59 +0530; 17min ago Process: 619 ExecStart=/home/665267/Integrated/DummyApp/DummyApp (code=dumped, signal=ABRT) CGroup: name=systemd:/system/TestService.service – Sid411 Dec 5 '14 at 10:41
  • @Sid411 - What is still asking for a login? Note that the environment variables passed to a service are different to the ones used at the shell by a logged in user. Maybe there is a variable that the application needs? See man systemd.exec for all your options. – garethTheRed Dec 5 '14 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.