Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Write an app to start and kill another app periodically
Re: Write an app to start and kill another app periodically [message #26391 is a reply to message #26388] Thu, 29 April 2010 19:18 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi jpderyck,

I'm not sure if you know what you really want Smile You were talking about GUI app on one side and periodical checks and service on the other. That doesn't get quite together Wink

If you want to have GUI, than what Koldo says is the good way for you to go. I just add other possibility, which doesn't require you to know process id: You can simply use the Sys function from U++ core:
Sys("killall -SIGXYZ app");
You can substitute the "SIGXYZ" with any of the signal names Koldo mentioned above, or omit it totally to use default SIGTERM.

The other option is a "service". Actually on linux it is called daemon, but basically it a same thing Wink That is just regular console application, and your system is set up to start or terminate it as necessary. This is usually done via initscripts. Some more advanced solutions (like upstart) also provide nice features like checking if the daemon runs, so it is restarted even when it terminates for some reason. Details depend on what distribution you use.

And there is also a third option. Don't write an U++ app at all. From what you said, I believe that all you need is a simple shell script
#!/bin/sh
# here should be some check to see if the app is running or if it hangs,
# that would depend on how it hangs and how you can test it ...
killall "yourapp"
/path/to/yourapp
Then you can set up cron to launch it periodically, let's say every 5 minutes:
echo $( crontab -l; echo '*\5 * * * * /path/to/the/script'
For more details about cron and how to use it see man cron and man crontab.

There is probably many more options, but I think the last one is just the one you need. Also it uses just standard tools, so it can be used on almost any system.

Best regards,
Honza

[Updated on: Thu, 29 April 2010 20:11]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [BUG&FIX] LocalProcess can not be reused
Next Topic: String.Mid() and Unicode
Goto Forum:
  


Current Time: Mon Jun 16 12:26:42 CEST 2025

Total time taken to generate the page: 0.04451 seconds