I have an application which is an object file (obtained from a c source code). When I run this application from the terminal it works fine.

I want to run this application on system start up. Since all the log data currently I am printing on the terminal, I want to open the terminal and run this application in terminal (so that I can see the live log and also give input to my application from terminal).

After searching some tutorials I am able to create a service which runs a shell script on startup. I modified this script to open a terminal and run the application. If I run the shell script only from the terminal it works well.

But when I am running the script from service I am getting following warning:

(x-terminal-emulator:16048): Gtk-WARNING **: cannot open display:

Where am I making mistake?

Here I am using beaglebone black running with debian.

This is my service code(application.service)

Description=application setup



Here is start_application.sh

#! /bin/sh
# start_app_server

echo "Starting application server"
x-terminal-emulator -e "app_server/a.out"

echo Done
  • 1
    You may want to use "screen". – dr0i Aug 11 '15 at 11:46

The *nix way of doing this would be to start the script without a terminal and send the output to a log file. For example:

app_server/a.out > /var/log/app_server.log &

You can then add it to the user crontab with @reboot.

Once that works, the real *nix way to do it is to create a service, with some form of IPC if necessary.

  • Thank you l0b0 for replying. Sorry I forgot to mention that I am using terminal not only for log but also to give some input to my application. I am working as per your suggestion; here object file runs in background but app_server.log is always empty. – Edge G Aug 11 '15 at 13:19
  • About logging, you'll want to have a look at I/O and process management, and afterwards maybe post a separate question. – l0b0 Aug 11 '15 at 18:14

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.