Note that these are just some examples, not a list of things that any particular user should have in their crontab¶
Nothing in here is a specific recommendation. DO NOT copy and paste this with the idea that saltbox team is suggesting that you should do all these things. They may not work as shown here, depending on your setup.
It's just a catalog of examples to demonstrate how one might set this sort of thing up.
There are scripts in here that DELETE files. DO NOT enable such things without understanding WHAT files will be deleted, WHY, and WHEN.
If you are unfamiliar with the syntax shown below, crontab generator can be useful, but you should be familiar with what cron does before blindly enabling things in this way.
Line 1PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin sets the PATH environment variable. - REQUIRED to use sb commands in cronjobs. e.g sb update
Line 2:plex-meta-manager script to make Plex collections. - [Runs midnight daily server time]
Line 3: Saltbox backup. - [Runs every Sunday @ 7AM server time] [This requires line 1]
Line 4: optimize the plex database using the plex-db tag. - [Runs daily @ 4AM server time] [This requires line 1]
Line 5: cleanup script to remove left over junk in /downloads/nzbs/nzbget/completed/sonarr/* etc. - [Runs every minute] Note: Scroll down for a couple ideas for this script.
Line 6: Different script to optimize the Plex database. - [Runs daily @ 10AM server time]
Note: Scroll down for script.
Note that this script is specific to its author's setup when it was written. It probably won't work for you as-is. You'll need to edit the paths to match your situation.
#!/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--requestPUThttp://plex:32400/library/optimize\?async=1\&X-Plex-Token=`cat/tmp/plex.tmp`
rm-f/tmp/plex.tmp