scripting - Is there a way to create a bash script that will only run for X hours? -


is there way create bash script run x hours? i'm setting cron job initiate script every night. script runs until condition met, exporting it's status holding variable keep track of 'where is' after each iteration. intention start-up process every night, run few hours, , stop, holding status until process starts next night.

short of somehow collecting start time, , checking against current time in each iteration of loop, there easier way this? bash scripting not forte (i know enough things done , dangerous) , have not done before. appreciated. thanks.

use gnu coreutils

gnu coreutils contains actual timeout binary, invoked this:

# timeout after 5 seconds when sleeping 30 /usr/bin/timeout 5s /bin/sleep 30 

in case, you'd want specify hours instead of seconds, timeout in 2 hours use 2h instead of 5s. see timeout(1) or info coreutils 'timeout invocation' additional options.

hacks , workarounds

native timeouts or gnu timeout command best options. however, see following ideas if decide roll own:

  1. how run command, , have abort (timeout) after n seconds?
  2. the tmout variable using read , process or command substitution.

Comments

  1. Thanks a lot for such a wonderful concept! I appreciate your concern about hiring a professional Python games developer for the businesses. It was a mind-blowing explanation that the experts helped eliminate the technical glitches that might affect the entire project execution. While administering my hiring team, I recently came across a wonderful platform EIliana.com which aided me in hiring experts for the company. I suggest the same for the people looking for similar assistance.

    ReplyDelete
  2. What we can say is that world777 fantasy sports are modeled after real-life sports, but with significant variations that make the game experience more engaging and enjoyable. Download the Howzat fantasy app and start playing to see how much fun it can be. It will change how you view your favorite sport.

    ReplyDelete

Post a Comment

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -