Skip to content

User crontab example

Chaz Larson edited this page Oct 10, 2019 · 36 revisions

Example user crontab for cloudbox users.

Note that this is just one example, not a list of things that any particular user should have in their crontab.

crontab -e

@daily /opt/python-plexlibrary/plexlibrary.sh
0 7 * * 7 sudo PATH='/usr/bin:/bin:/usr/local/bin' env ANSIBLE_CONFIG='/home/seed/cloudbox/ansible.cfg' '/usr/local/bin/ansible-playbook' '/home/seed/cloudbox/backup.yml' -v  >> '/home/seed/logs/cloudbox_backup.log' 2>&1
@daily curl -s https://cloudbox.works/scripts/repo.sh | bash >/dev/null && cd ~/cloudbox
* * * * * /opt/scripts/nzbget/cleanup.sh
0 10 * * * /opt/scripts/plex/optimize.sh
0 * * * * PATH='/usr/bin:/bin:/usr/local/bin' cd /opt/SonarrSync/ ; /usr/bin/python SonarrSync.py

Line 1: python-plexlibrary script to make Plex libraries. Installed automatically with run of Cloudbox role. - [Runs midnight daily server time]

Line 2: Cloudbox backup. - [Runs every Sunday @ 7AM server time]

Line 3: Cloudbox repo.sh script to update Cloudbox and do auto-updates for you - [Runs daily]

Line 4: rxwatcher's cleanup script to remove left over junk in /downloads/nzbs/nzbget/completed/sonarr/* etc. - [Runs every minute] Note: Scroll down for script.

Line 5: Script to optimize the Plex database. - [Runs daily @ 10AM server time] Note: Scroll down for script.

Line 6: Enormoz's SonarrSync (based on Sperryfreak's RadarrSync) - [Runs hourly]


RXWatcher's cleanup.sh

 more nzbget_cleanup.sh
#!/bin/bash
find /mnt/local/downloads/nzbget/completed/sonarr/* -type d -mmin +60 -ls -exec rm -rf {} + 2>/dev/null
find /mnt/local/downloads/nzbget/completed/radarr/* -type d -mmin +60 -ls -exec rm -rf {} + 2>/dev/null
find /mnt/local/downloads/nzbget/completed/books/*  -type d -mmin +240 -ls -exec rm -rf {} + 2>/dev/null
find /mnt/local/downloads/nzbget/completed/sonarr/* -type d -mmin +60 -ls -exec rm -rf {} + 2>/dev/null
find /mnt/local/downloads/nzbget/completed/radarr4k/* -type d -mmin +60 -ls -exec rm -rf {} + 2>/dev/null
find /mnt/local/downloads/nzbget/completed/anime/* -type d -mmin +60 -ls -exec rm -rf {} + 2>/dev/null

RXWatcher's optimize.sh

#!/bin/sh
# Get the contents of the Preferences file, keep only what we need,  push to a temp, then use it in the curl command

cat "/opt/plex/Library/Application Support/Plex Media Server/Preferences.xml" |  \
sed -e 's;^.* PlexOnlineToken=";;' | sed -e 's;".*$;;' | tail -1 > /tmp/plex.tmp

curl --request PUT http://127.0.0.1:32400/library/optimize\?async=1\&X-Plex-Token=`cat /tmp/plex.tmp`

rm -f /tmp/plex.tmp

Install Guides

Repository

Apps

Misc Guides

General Stuff

Linux Stuff

Plex

Organizr

Downloading

STRM

Clone this wiki locally