0

My first posting, so learning this askubuntu posting system. I'm trying to automate my Ubuntu 14.04LTS server using Ubuntu's Startup Applications. I automatically start several bash scripts within gnome-terminal windows when the pc is restarted. However my C program quits running after about 10 minutes to an hour when starting it via the Startup Applications.

Here is an example of a Startup Applications Command that works:

gnome-terminal -x sh -c "notifyserial.sh; #!/bin/bash"

(works fine, scripts continue to run, monitoring processes, terminal window stays active)

My "c program" called "serial" starts and is updating print statment like below:

   Command: 14 01 - Cashless Reader Enable

   Starting main loop

   ********************************************************************

   Started    **serial**    program at : Wed Sep 27 17:19:27 2017

   ********************************************************************

After about 10-20 minutes the program stops and this shows in yellow at the top of the terminal window:

The child process exited normally with status 139.

Within "Startup Applications" I have tried adding the following commands, reboot the computer, then wait and see if the "serial" program continues to run indefinitely, however it does not:

gnome-terminal -x sh -c "sudo ./myprogram"

and

gnome-terminal -e  "sudo ./myprogram"

and

gnome-terminal -x sh -c "startserial.sh; #!/bin/bash" && DISPLAY=:0 && wmctrl -r :ACTIVE: -b toggle,shaded

When I have the terminal profile set to "Hold the terminal open" I get this:

The child process exited normally with status 139.

When I have the terminal profile set to "Exit the terminal" the terminal window disappears.

I tried putting the various commands in a bash script since my other scripts stay working indefinitely as they are supposed to. I the bash script startserial.shI tried each of these command lines individually rebooted and waited for the results:

#!/bin/bash
#gnome-terminal -e "/home/cpi-machine3/serial_ver2_machine3_75centair_3_95"  --window-with-profile-internal-id=b9dc7b22-e86b-4ab0-9cdd-4470e1ed6b9
#/home/cpi-machine3/serial
#gnome-terminal -x sh -c "sudo ./serial"

I have started this program with gnome terminal by opening terminal: clicking on terminal icon or by ctrl + alt + t and type:

sudo ./serial

Then press enter. My program runs for weeks. Gnome Terminal stays active showing all the print commands to the screen as I programmed.

My goal is to have c program, "serial" automatically start and keep running when the pc reboots from: 1. a power outage 2. I remotely reboot the pc with Teamviewer or 3. reboot through Gnome Schedule v2.2 on a recurring schedule.

Replies:

Tried this in terminal but it quit after about 20 minutes (same issue):

gnome-terminal -x bash -c "sudo /home/cpi-machine3/serial"

From the feed back I will try this command in bash script:

 gnome-terminal -x bash -c "sudo /home/cpi-machine3/serial"

In the upcoming terminal you're been asked for the root password and enter it, am I correct there?

Not now I typed a command and no longer need to enter the password.

Is your program meant to be run as root?

I don't know. "serial" resides in my '/home' directory. And I start it from there. It does not run unless I use 'sudo'

is it meant to be a system service? I'm not sure what that means.

This is a new issue: I started my "serial" normally by opening a terminal window (clicking on the terminal icon) and now my program is ending. The command prompt appeared just like pressing ctrl + c to break out of my program. This has not happened before, on either of my pc's running this program.

  Command: 14 01 - Cashless Reader Enable
  Starting main loop
  ********************************************************************
   Started    **serial**    program at : Wed Sep 27 17:44:11 2017

  ********************************************************************
  cpi-machine3@CPI-Machine3:~$ 
3
  • 1
    Is your program meant to be run as root? is it meant to be a system service? It's not quite clear what exactly you're trying to do from your question.
    – dobey
    Sep 27, 2017 at 18:48
  • 1
    Well, if your process is exiting with status code 139, that is not normal. You should debug from there I think, to find out what's going on.
    – dobey
    Sep 28, 2017 at 1:32
  • I'm voting to close this now as it's unclear what you're asking – you try to start notifyserial.sh, myprogram, startserial and serial and it's totally vague which is supposed to do what, as (plus) you provide no script content at all.
    – dessert
    Sep 28, 2017 at 6:38

1 Answer 1

1

I finally realized my C program had an error causing it fail 10 minutes to an 1 hour after running. It was not the Terminal having issues. I am still unable to automatically start my C program in the Startup Applications program. So I will do some more trouble shooting and post that question later if I need help.

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.