DrivePolling
Aus Programmers Guide
(Unterschied zwischen Versionen)
Roy (Diskussion | Beiträge) |
Roy (Diskussion | Beiträge) |
||
Zeile 15: | Zeile 15: | ||
#/etc/backup-platten-polling | #/etc/backup-platten-polling | ||
+ | #folder to check for drives | ||
device="/dev/disk/by-id/" | device="/dev/disk/by-id/" | ||
- | + | #this is the device ID | |
platte1="usb-BUFFALO_HD-PXU2_001010070301C5160-0:0-part1" | platte1="usb-BUFFALO_HD-PXU2_001010070301C5160-0:0-part1" | ||
+ | #folder to store the lock files (lock files named by id) | ||
+ | lock="/var/lock/" | ||
+ | #mail-recipient | ||
mailadresse="script@firma.de" | mailadresse="script@firma.de" | ||
cd $device | cd $device | ||
- | |||
if ls -l| grep "$platte1">/dev/null | if ls -l| grep "$platte1">/dev/null | ||
then | then | ||
Zeile 52: | Zeile 55: | ||
</source> | </source> | ||
- | + | [[Category:Bash]] [[Category:Ubuntu]] | |
- | + | ||
- | [[Category:Bash]][[Category:Ubuntu]] | + |
Aktuelle Version vom 07:01, 2. Nov. 2010
Script to Check if Disk Status Changes
Run this Script in the Local Crontab:crontab -e #*/5 * * * * root bash /etc/backup-platten-polling > /dev/null 2>&1
If the online Status changes, the script create or delete the lock file in /var/lock/
If the lockfile is available, you can Backup Data or use the disk for other work.
#!/bin/bash # #/etc/backup-platten-polling #folder to check for drives device="/dev/disk/by-id/" #this is the device ID platte1="usb-BUFFALO_HD-PXU2_001010070301C5160-0:0-part1" #folder to store the lock files (lock files named by id) lock="/var/lock/" #mail-recipient mailadresse="script@firma.de" cd $device if ls -l| grep "$platte1">/dev/null then echo "Platte 1 verbunden" cd $lock if ls -l|grep "$platte1">/dev/null then echo "pl 1 nothing to do" else echo "pl 1 file anlegen" echo "Erste Backup-Platte wurde erfolgreich verbunden und die Nacht zum Backup herangezogen." | mail -s "Festplatte 1 verbunden" $mailadresse touch "$platte1" fi cd $device else echo "Platte 1 getrennt" cd $lock if ls -l|grep "$platte1">/dev/null then echo "pl 1 auswerfen" rm "$platte1" echo "Erste Backup-Platte wurde getrennt." | mail -s "Festplatte 1 getrennt" $mailadresse else echo "pl 1 nix zu tun" fi cd $device fi exit 0