3

I'm using unison to synchronise data to a server, and I've recently created a cronjob for this. The cronjob is running at startup and saves the output to a log file. (additional info below).

The problem I'm having is that unison has quite a lot of output, and I'd like to only save the summary to the log file. Is there a way to do that? I haven't found a way to make unison less verbose, so I thought maybe the output can be filtered somehow - I just wouldn't know how.

Thanks!

Additional info:

Right now, the log file ends up looking like this:

Contacting server...
Connected [//theserver//share/HDA_DATA/elrudi -> //thelaptop//home/elrudi]
Looking for changes
\ syncAll/Code/Aptana/T...avascript library code assist.txt

\ syncAll/Code/develope...nk/20070607 contacten (INDEX).xls

\ syncAll/Code/sourcefi...okexport/photos/10152112061815397

| syncAll/Code/Python/d...rawable-hdpi/ic_action_search.png

(... many many lines ...)

| syncAll/Work/2008_10 ...profile/StandardLastprofil_H0.xls

| syncAll/Work/2008_10 ...n/Load Profiles/Lastprofil_H0.xls

Waiting for changes from server
Reconciling changes
changed  ---->            syncAll/scriptfile1.sh 
Propagating updates
UNISON 2.40.102 started propagating changes at 12:07:31.55 on 07 Oct 2015
[BGN] Updating file syncAll/scriptfile1.sh from /home/elrudi to //theserver//share/HDA_DATA/elrudi
100%  00:00 ETA

[END] Updating file syncAll/scriptfile1.sh
100%  00:00 ETA

UNISON 2.40.102 finished propagating changes at 12:07:31.61 on 07 Oct 2015
100%  00:00 ETA

Saving synchronizer state
Synchronization complete at 12:07:36  (1 item transferred, 0 skipped, 0 failed)

I'd want to ditch the lines starting with |, /, -, or \ (the spinning bar indicating a process is not finished yet).

More additional info:
crontab -e shows

@reboot /home/elrudi/sync.sh -batch 60 >> /home/elrudi/.cronjobs.log 2>&1   

The sync.sh script checks whether the server is locally reachable or remotely, and runs the appropriate unison command. The -batch parameter is added to make unison run without user input, and the 60 is a waiting time (to make sure unison does not run before a connection is available).

ElRudi
  • 299

1 Answers1

6

When you call unison in your sync.sh script call it as follows:

unison ... 2>&1 | grep -vE '^[\|/-]|^$'

This will remove (-v) all line that match the regual expression: All line beginning with one of those characters: \|/-, or complete empty lines (^$).


Edit: If you want the cronjob to be filtered, use:

@reboot /path/to/sync.sh -batch 60 2>&1 | grep -vE '^[\|/-]|^$' >> /path/to/logfile
chaos
  • 28,186