[GRASS5] "sync" in scripts

Hamish hamish_nospam at yahoo.com
Mon Nov 14 20:28:05 EST 2005


> > how portable is it to use the "sync" command in shell scripts?
> > Currently a couple of scripts that use the netpbm tools use a "sleep
> > 1" command to wait for the disk write, but sync is more appropriate?
> 
> What is the reason for running "sync"?
> 
> AFAIK, the only useful reason for calling sync is if you want the
> following command(s) to run as fast as possible without being slowed
> down by excessive disk access.

The problem is that "d.mon stop=PNG" exits before the file is fully
written? When you try to do an immediate 'pngtopnm $out | pnmtojpeg'
conversion on the output map.png you get error message complaining about
failing to get magic number or something like that. Running "sync" to
flush the drive buffer or simply "sleep x" cures the problem.

e.g. the d.out.gpsdrive and d.out.file scripts.

given that sleep/sync is a cure to a symptom, not the cause.


Hamish




More information about the grass-dev mailing list