Istvan Gabor wrote:
Hello:
I have a program which saves data in a file. It writes the file when the user quits the program. I would like to automatically save a copy of the data file when/after the program quits. How can I achieve that?
The info you give is a little sparse. If the suggested program ; cp .... (I'd probably use program && cp .... ) is not an option, another way could be using inotifywait. But that will only work if the file is always the same, or at least written to the same directory. E.g., I run a script (permamnently in background) that watches when my observers change a config file, and then saves a timestamped copy to a separate directory. Maybe it gives some inspiration :) #!/bin/sh file=/home/obs/CHROMIS/linedef.py dn=$(dirname $file) fn=$(basename $file) archive=/root/CHROMIS-calibarchive inotifywait -q -m -e close_write --format %f $dn | \ while read line ; do if [ $line = $fn ]; then cp $file $archive/$fn-$(date +%Y.%m.%d-%H:%M:%S) ; fi ; done -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org