Code to start an application manually, then quit and restart
Code to start an application manually, then quit and restart
Hi, looking for some correct code to quit and restart an application.
1. Start Application manually. (The desktop File will call the shellscript with the following commands)
2. After 40 seconds, Application quits.
3. After 5 seconds, Application starts up again.
4. Repeats 2 and 3 ten times.
I don't think cron has the granularity of anything less than a minute, and I did try some exotic jiggery pokery with timer delays, but if the sleep command works properly in puppy then that should do the task ok?
Plus I couldn't find the presets I made in Ziggy's PSchedule (nothing in vary/spool/crontab) and anyways, have to wait for a minute for command number 3. to function..
1. Start Application manually. (The desktop File will call the shellscript with the following commands)
2. After 40 seconds, Application quits.
3. After 5 seconds, Application starts up again.
4. Repeats 2 and 3 ten times.
I don't think cron has the granularity of anything less than a minute, and I did try some exotic jiggery pokery with timer delays, but if the sleep command works properly in puppy then that should do the task ok?
Plus I couldn't find the presets I made in Ziggy's PSchedule (nothing in vary/spool/crontab) and anyways, have to wait for a minute for command number 3. to function..
-
- Posts: 168
- Joined: Fri 26 Jan 2018, 20:54
Ok, I was being hardline on the 40 secs bit, it will eventually be 40 mins, but I wanted to test the script without waiting for that amount of time to see if it works.
But I definitely don't want to wait a minute for an application to restart.
It's a bug tester.
Two applications Burn IT? Fire away lol. Can't even think of that method atm.
Matchpoint if you have something appropriate could you post the condensed code here please?
But I definitely don't want to wait a minute for an application to restart.
It's a bug tester.
Two applications Burn IT? Fire away lol. Can't even think of that method atm.
Matchpoint if you have something appropriate could you post the condensed code here please?
-
- Posts: 168
- Joined: Fri 26 Jan 2018, 20:54
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Maybe something like this:
Create a desktop icon with contents as in screenshot.
Here again the arguments for /bin/bash:
When clicking on the desktop icon the program (here gxmessage -c "No. $i of 5", but can be any other program) will start.
Program quits after 4 sec.
After another 3sec program starts again.
This will repeat 5 times.
Create a desktop icon with contents as in screenshot.
Here again the arguments for /bin/bash:
Code: Select all
-c 'for i in {1..5}; do timeout -t4 gxmessage -c "No. $i of 5" ; sleep 3; done'
Program quits after 4 sec.
After another 3sec program starts again.
This will repeat 5 times.
- Attachments
-
- StartStopCycletest.png
- (17.68 KiB) Downloaded 190 times
Last edited by MochiMoppel on Sun 18 Mar 2018, 13:32, edited 2 times in total.
-
- Posts: 168
- Joined: Fri 26 Jan 2018, 20:54
I wondered why it wouldn't run for me.MochiMoppel wrote:Here again the arguments for /bin/bash:Code: Select all
-c 'for i in {1..5}; do timeout -t4 gxmessage -c "No. $i of 5" ; sleep 3; done'
The timeout command would give me error "timeout: invalid option -- 't' "
Found answer after searching in "man timeout" and timeout command in "man busybox".
It seems Fatdog is using coreutil's timeout which just needs a number to specify time in sec. (you can also use suffix 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.)
And what MochiMoppel's code uses is busybox's timeout, which is what all Pups use.
Thanks MochiMoppel for the code. I learned something new today.
I will go slightly off-topic and ask couple of questions,
1) Is there a way to specify time in minutes or hours while using busybox's timeout. I couldn't find it.
2) While using "man" or "info" command is there a way to go to directly timeout or any other sub command in busybox? I had to scroll down really long man page of busybox.
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Apparently not. Or use -t $((60*60*5)) if you need a timeout of 5 hours.drunkjedi wrote:1) Is there a way to specify time in minutes or hours while using busybox's timeout.
"info"? And "man" is a symlink to BK's script pman, quite different from the original man command, which is not installed in my Slacko.2) While using "man" or "info" command is there a way to go to directly timeout or any other sub command in busybox? I had to scroll down really long man page of busybox.
I normally find busybox's --help option sufficient:
Code: Select all
# busybox timeout --help
BusyBox v1.21.0 (2013-02-18 15:57:06 WST) multi-call binary.
Usage: timeout [-t SECS] [-s SIG] PROG ARGS
Runs PROG. Sends SIG to it if it is not gone in SECS seconds.
Defaults: SECS: 10, SIG: TERM
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
OK, that might explain why I've never seen them. I never load devx sfs.
If timeout command causes problems and intervals should be specified in minutes or hours, here is a solution that avoids timeout and uses sleep - sleep can even be specified in daysStores the PID of the just started command in a variable, waits for the specified interval, then kills the command. After a 3 sec mourning period starts all over again. A serial killer app.
If timeout command causes problems and intervals should be specified in minutes or hours, here is a solution that avoids timeout and uses sleep - sleep can even be specified in days
Code: Select all
for i in {1..5}; do gxmessage -c "No. $i of 5" & CPID=$! ; sleep 4 ; kill $CPID ; sleep 3; done