[SOLVED] background watch command
by ychaouche from LinuxQuestions.org on (#5AR2X)
Dear #LQ,
I am using a particular editing software on a laptop that has a dead battery. Anytime the power line disconnects, the laptop shuts off immediately. The software I am using seems to be buggy : even if I save the file manually a number of times while working on it, it might wipe out all the data from the saved file (file size becomes 0) on power failures, and this somtimes means hours of worked lost.
Frustrated, I thought about a naive way of working around this : I would have a watch command that would make a backup copy of the file i'm working :
Code:$ watch cp file file.bakthis works as long as watch is running in the foreground. But if I run the program with an ampersand
Code:$ watch cp file file.bak &It won't run, probably because it needs to write to stdout to show it's output (which I'm not interested in) so it stops running (maybe)
Is there a way to still get it running in the background without resorting to cron ?
Code:chaouche@q4os-desktop ~/NOTES/ITIL $ jobs
[1] Running vym &
[2]+ Stopped watch cp itil.vym itil.vym.bak
[3]- Running firefox --no-remote -P default 2> /dev/null &
chaouche@q4os-desktop ~/NOTES/ITIL $


I am using a particular editing software on a laptop that has a dead battery. Anytime the power line disconnects, the laptop shuts off immediately. The software I am using seems to be buggy : even if I save the file manually a number of times while working on it, it might wipe out all the data from the saved file (file size becomes 0) on power failures, and this somtimes means hours of worked lost.
Frustrated, I thought about a naive way of working around this : I would have a watch command that would make a backup copy of the file i'm working :
Code:$ watch cp file file.bakthis works as long as watch is running in the foreground. But if I run the program with an ampersand
Code:$ watch cp file file.bak &It won't run, probably because it needs to write to stdout to show it's output (which I'm not interested in) so it stops running (maybe)
Is there a way to still get it running in the background without resorting to cron ?
Code:chaouche@q4os-desktop ~/NOTES/ITIL $ jobs
[1] Running vym &
[2]+ Stopped watch cp itil.vym itil.vym.bak
[3]- Running firefox --no-remote -P default 2> /dev/null &
chaouche@q4os-desktop ~/NOTES/ITIL $