Tag Info

New answers tagged

-1

Since you're using bash anyway, you should be using $SECONDS: #!/bin/bash while [ "$SECONDS" -lt 5 ] || { SECONDS=$((i=0)) echo Something different };do sleep "$((r=(1+RANDOM)%3))" echo "$((i+=r))" done From man bash: $SECONDS This variable expands to the number of seconds since the shell was started. Assignment to this ...


1

Here is the code I am running now, based on airfishey's answer with some corrections. #!/bin/bash t_lastdue=$(date --date='5seconds ago' +%s) while true do t_now=$(date +%s) t_elapsed=$((t_now - t_lastdue)) if [ $t_elapsed -ge 5 ] then echo 'Something different' t_lastdue=$((t_lastdue + 5)) i=0 else # ...


3

First of all, in case it isn't obvious, the script in the question fails because heartbeat runs in a child process, and therefore cannot change shell variables in the parent shell's memory. Here's an approach that's closer to the spirit of the OP's attempt: #!/bin/bash trap 'do_different=true' USR1 heartbeat() { while sleep 5 do ...


1

I would use the date utility to get the current time in seconds. #!/bin/bash lastTime=-5 while true do currentTime=$(date +%s) elapsedTime=$((currentTime - lastTime)) if [[ $elapsedTime -ge 5 ]] then echo 'Something different' lastTime=$currentTime i=0 else # process of random duration; not important ...


0

This happened to me about two months ago. Don't worry chances are that it is locked up. If your computer has an external battery pull it out. If your computer doesn't have a battery, close it flip it upside-down, then there is a pin hole. if your computer has this use a paperclip or staple to press the button inside the hole. (kinda like the reset buttons ...


0

Here is how it can be done In Cinnamon Open system settings Choose Keyboard Choose Keyboard Shortcuts Choose Custom Shortcuts Choose Add Custom Shortcut Enter name as "Printer off and Sleep" Enter comand as gnome-terminal -x bash -c "curl http://192.168.1.50/?s2-1off; echo password | sudo -S pm-suspend" Press Add. Double click a keyboard binding to ...



Top 50 recent answers are included