DrivePolling
Aus Programmers Guide
(Unterschied zwischen Versionen)
Roy (Diskussion | Beiträge) |
Roy (Diskussion | Beiträge) |
||
Zeile 9: | Zeile 9: | ||
If the lockfile is available, you can [[ScriptBackup|Backup Data]] or use the disk for other work. | If the lockfile is available, you can [[ScriptBackup|Backup Data]] or use the disk for other work. | ||
+ | |||
<source lang="bash"> | <source lang="bash"> | ||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
#/etc/backup-platten-polling | #/etc/backup-platten-polling | ||
+ | |||
device="/dev/disk/by-id/" | device="/dev/disk/by-id/" | ||
lock="/var/lock/" | lock="/var/lock/" | ||
Zeile 44: | Zeile 46: | ||
echo "pl 1 nix zu tun" | echo "pl 1 nix zu tun" | ||
fi | fi | ||
- | |||
cd $device | cd $device | ||
fi | fi |
Version vom 06:57, 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 device="/dev/disk/by-id/" lock="/var/lock/" platte1="usb-BUFFALO_HD-PXU2_001010070301C5160-0:0-part1" 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