Last active
April 23, 2017 17:05
-
-
Save AloiSama/a30282933f3bb5081ebe9ceedb91776d to your computer and use it in GitHub Desktop.
Media Server CRONJOBS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Change paths for mount and log file & create mountcheck file. | |
| # Add script to crontab by typing crontab -e and pasting the line below (without # in front ) | |
| # * * * * * /home/scripts/fuse-mount.cron >/dev/null 2>&1 | |
| # Make script executable with: chmod a+x /home/scripts/fuse-mount.cron | |
| logfile="/home/scripts/logs/fuse-mount.cron.log" | |
| if pidof -o %PPID -x "fuse-mount.cron"; then | |
| echo "$(date "+%d.%m.%Y %T") EXIT: fuse-mount.cron already running." | |
| exit 1 | |
| fi | |
| if [[ -f "/home/tv/mountcheck" ]]; then | |
| echo "$(date "+%d.%m.%Y %T") INFO: Check successful, fuse mounted." | tee -a "$logfile" | |
| exit | |
| else | |
| echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress." | tee -a "$logfile" | |
| # Unmount before remounting | |
| fusermount -uz /home/tv | tee -a "$logfile" | |
| /usr/bin/unionfs-fuse -o cow,allow_other,nonempty /home/plex-tv-r=RW:/home/gd-tv=RO /home/tv | |
| if [[ -f "/home/tv/mountcheck" ]]; then | |
| echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile" | |
| else | |
| echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile" | |
| fi | |
| fi | |
| exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hostname:/home/scripts# ls -l | |
| total --K | |
| -rwxr-xr-x 1 root root 1.1K Apr 16 02:30 fuse-mount.cron | |
| drwxr-xr-x 2 root root 4.0K Apr 17 02:43 logs | |
| -rwxr-xr-x 1 root root 1.2K Apr 23 10:53 mount-m.cron | |
| -rwxr-xr-x 1 root root 1.2K Apr 16 02:04 mount-tv.cron | |
| -rwxr-xr-x 1 root root 721 Apr 23 10:59 upload-m.cron | |
| -rwxr-xr-x 1 root root 716 Apr 23 10:59 upload-tv.cron |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Change paths for mount and log file & create mountcheck file. | |
| # Add script to crontab by typing crontab -e and pasting the line below (without # in front ) | |
| # * * * * * /home/plex/scripts/mount.cron >/dev/null 2>&1 | |
| # Make script executable with: chmod a+x /home/scripts/mount.cron | |
| logfile="/home/scripts/logs/mount-tv.cron.log" | |
| if pidof -o %PPID -x "mount-tv.cron"; then | |
| echo "$(date "+%d.%m.%Y %T") EXIT: mount-tv.cron already running." | |
| exit 1 | |
| fi | |
| if [[ -f "/home/gd-tv/mountcheck" ]]; then | |
| echo "$(date "+%d.%m.%Y %T") INFO: Check successful, gd-tv mounted." | tee -a "$logfile" | |
| exit | |
| else | |
| echo "$(date "+%d.%m.%Y %T") ERROR: Drive not mounted, remount in progress." | tee -a "$logfile" | |
| # Unmount before remounting | |
| fusermount -uz /home/gd-tv | tee -a "$logfile" | |
| rclone mount \ | |
| --read-only \ | |
| --allow-non-empty \ | |
| --allow-other \ | |
| --max-read-ahead 200M \ | |
| --checkers 16 \ | |
| --quiet \ | |
| --stats 0 \ | |
| egdtv:/LIBRARY/TV /home/gd-tv/& | |
| if [[ -f "/home/gd-tv/mountcheck" ]]; then | |
| echo "$(date "+%d.%m.%Y %T") INFO: Remount successful." | tee -a "$logfile" | |
| else | |
| echo "$(date "+%d.%m.%Y %T") CRITICAL: Remount failed." | tee -a "$logfile" | |
| fi | |
| fi | |
| exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # RCLONE UPLOAD CRON TAB SCRIPT | |
| # Type crontab -e and add line below (without # ) | |
| # * * * * * root /home/scripts/upload-tv.cron >/dev/null 2>&1 | |
| if pidof -o %PPID -x "upload-tv.cron"; then | |
| exit 1 | |
| fi | |
| LOGFILE="/home/scripts/logs/upload-tv.cron" | |
| FROM="/home/plex-tv-r/" | |
| TO="egd1:/LIBRARY/TV" | |
| # CHECK FOR FILES IN FROM FOLDER THAT ARE OLDER THEN 15 MINUTES | |
| if find $FROM* -type f -mmin +15 | read | |
| then | |
| echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD STARTED" | tee -a "$LOGFILE" | |
| # MOVE FILES OLDER THEN 15 MINUTES | |
| rclone move $FROM $TO -c --no-traverse --transfers=10 --checkers=10 --delete-after --min-age 15m --log-file="$LOGFILE" | |
| echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD ENDED" | tee -a "$LOGFILE" | |
| fi | |
| exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment