Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] Trouble with cron jobs

Featured Replies

I've been trying to automate the backup of my Mysql database by putting a script in cron.hourly (for testing, will move to daily when done.)  So far, no luck,  The script does run from the command line.

#! /bin/bash
#Mysql Backup
/usr/bin/mysqldump -u root -proot newznab | gzip > /mnt/user/Backup/Mysql/newznab_`date +%Y%m%d`.sql.gz

I did make it executable so permissions shouldn't be a problem.  I suspect there may be a problem in connection with my upgrade to V5.  Previously, under 4.7 I had, through Unmenu, monthly parity checks and emails concerning status.  These stoped working after the upgrade.  When upgrading, I added Simplefeatures and various plugins.  Thinking that maybe Simplefeatures plugins were causing a problem, I disabled all but the web gui and webserver, still no luck running the cron job.  I'm am still running other plugins (SABnzbd, Couch Potato, Headphones, Sickbeard, Newznab, Mysql, PS3 Media Server.)  Any thoughts?

You could just put the below line under the regular cron (/var/spool/cron/crontabs/root) to run hourly.

0 * * * * mysqldump -u root -proot newznab | gzip > /mnt/user/Backup/Mysql/newznab_`date +%Y%m%d`.sql.gz

 

I have a few lines that I add to my cron (runs spotweb updates & backs up my dbs). I created a file named /boot/custom/mycron that contains all my custom jobs & to make sure it is added every time I reboot, this is in my go file:

# Add custom jobs to crontab
cat /boot/custom/mycron >> /var/spool/cron/crontabs/root

  • Author

Tried Lainie, doesn't work.  I suspect one of my plugins may be the culprit, I'll try disabling one at a time and see what happens.

  • Author

Turns out my PS3Media Server  installation was causing a problem resulting in crond segfaults.  I replaced it with Serviio, my cron job now runs.  On a side note, can you script gurus suggest  some modification of my previouslly posted  Mysql backup script that would delete previous backups that were say 2 days old as I would at most want to keep 2 backups.  Thanks. 

On a side note, can you script gurus suggest  some modification of my previouslly posted  Mysql backup script that would delete previous backups that were say 2 days old as I would at most want to keep 2 backups.  Thanks.

 

Can be done with one line. Look at the manpage for the "find" command. Here is an example of what you want.

 

find /mnt/user/Backup/Mysql/ -mtime +2 -name newznab* -type f -exec rm -rf {} \;

 

This command will do a search in /mnt/user/Backup/Mysql/ for all files that were last modified 2 or more days ago and executes a recursive forced (-rf) remove (rm). The "{}" (curly braces) is the place holder for exec to use where it will put the name of the file, and the "\;" tells exec that's the end of the statement. Find is very powerful, and I suggest you do some reading BEFORE you do any removing using "find". Also, as a test you can replace the "rm -rf" with "ls -la" to get a list of all the files that would be removed.

  • Author

Thanks.  Got the script working.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.