python - linux-watch command: show time remaining -


i posted thread: run python script everytime computer wakes hibernation

i thinking of alternative countdown, show on console time remaining till command ran again.

for example script

import os os.system("watch -n 50 command") 

the console shows every 50 seconds run: command know of way show actual state of 50 seconds?

i think there no way unless command creates information (e. g. timestamp after execution or similar). reason simple: watch simple enters nanosleep() system call wait 50 seconds. (you can find out using strace.) nanosleep() nothing else wait 50 seconds. not provide information anywhere on how long sleep has been going on or how long still take. information buried deep inside kernel will, eventually, wake process again.

so, way making command render information, e. g. letting touch timestamp file (e. g. touch /tmp/command.timestamp) time can used determine indirectly when next sleep finished.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -