Skip to content

Instantly share code, notes, and snippets.

@alkcxy
Created January 4, 2016 17:38
Show Gist options
  • Save alkcxy/fa8c095719c22d7115d2 to your computer and use it in GitHub Desktop.
Save alkcxy/fa8c095719c22d7115d2 to your computer and use it in GitHub Desktop.
This script copies fits images from a windows machine to a linux server. The script runs on linux.
#!/bin/bash
#change settings
sambashare=$HOME/samba
sambayear=$sambashare/2016
image=/media/ara/Immagini/src/
logfile=$HOME/logs/$nomeprogramma.log
serverip=192.168.1.6
# end change settings
inizio=`date +%s`
datan=`date "+%Y/%m/%d %H:%M"`
nomeprogramma=sincronizza
mypidfile=$HOME/pids/$nomeprogramma.pid
if [ -f $mypidfile ]; then
echo "$nomeprogramma è già in esecuzione" >> $logfile
exit 1;
fi
# PID file is removed on program exit.
trap "rm -f -- '$mypidfile'" EXIT
ping -c 3 $serverip > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "macchina windows spenta il $datan" >> $logfile
exit 1;
fi
# Create a file with current PID to indicate that process is running.
echo $$ > "$mypidfile"
if [ ! -d $sambayear ]; then
echo "mount della cartella condivisa in corso" >> $logfile
mount $sambashare >> $logfile
fi
if [ -d $sambayear ]; then
rsync -avz --progress --chmod=ugo=rwX $sambayear $image
echo "Effettuata copia file" >> $logfile
fi
fine=`date +%s`
echo "Operazione eseguita in $(($fine-$inizio)) secondi il $datan" >> $logfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment