Restarting same program numerous times with Shell.

Linux specific questions.
Post Reply
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Restarting same program numerous times with Shell.

Post by Dinosaur »

Hi All

I want to restart a program at midnight every night.
Rebooting the Beaglebone black is not an option as even though it is battery backed, it loses date/time when rebooting.
So I investigated a script method , but because I am using Xorg without a window manager, Xorg terminates when my program exits.
Then tried using the return value of the program to restart it, but it got more & more complicated.

Found on searching on the forum a post by fxm, that used shell to start another program (fxm used notepad) and then quitting the original program after a sleep worked. In my case I simply restarted the same program.

My question:
What are the implications of doing this every day for months on end ?
Am I going to eat up memory and eventually crash ?
I guess I can read memory available but not sure how reliable that reading is, as other activity could corrupt that info.


Regards
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Restarting same program numerous times with Shell.

Post by MrSwiss »

Dinosaur wrote:I want to restart a program at midnight every night.
Fine, no problem but: NOT with Shell.
Use a second program, started from first before exit, to restart the original.

This is a tried and tested method, used in industrial environment by my application.
I've called mine simply: reStart, it terminates itself after launching original again.
Is running for about +10 years, by now (automotive industries).

This should also answer the additional questions you've listed.
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: Restarting same program numerous times with Shell.

Post by Dinosaur »

Hi All

Thanks for the reply MrSwiss.

I haven't used "Run" command since my QBasic days, so it wasn't even on my radar.
So the solution was to simply check for a serial time less then 2 sec's (was worried about repeated reStarts) and:

Code: Select all

Shell "free -b"
shows bytes of free memory stable for at least 10 tries.

Regards
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Restarting same program numerous times with Shell.

Post by TJF »

Dinosaur wrote:My question:
What are the implications of doing this every day for months on end ?
Am I going to eat up memory and eventually crash ?
I guess I can read memory available but not sure how reliable that reading is, as other activity could corrupt that info.
Either
  • SLEEP your program until next day (do not exit, but run it as a daemon=background process), or
  • define a cron job in the operating system
Post Reply