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.

Crontab is running in circles?

Featured Replies

I' m trying to add custom job to my crontab, which as script that does a backup of mysql database:

 

Script: backup_mysql.sh:

 

"/usr/bin/mysqldump -u root -ppassword --all-databases > /mnt/user/Backup/MySQL/dumps/mysql_backup__`date +%Y_%m_%d_%s`.sql"

 

Now, I run this script to add a job to crontab:

 

crontab -l >/tmp/crontab

echo "#backup mysql at 9 PM" >>/tmp/crontab

echo "* 21 * * * /boot/custom/backup_mysql.sh 1> /dev/null" >>/tmp/crontab

crontab /tmp/crontab

cp /tmp/crontab /var/spool/cron/crontabs/root-

 

The line is added to crontab

 

The job executes, however it seems to be executing over and over. Once the dump file is created, another backup jobs starts. I am not sure how to fix it?

 

I'am running unRaid 5.0-rc10

I'd say it is time four you to type

crontab -l

and post the output for analysis.  I'll suspect it is not as you expect.

 

Also, it is not necessary to copy /tmp/crontabs to /var/spool/cron/crontabs/root-

I'd skip that step.  (It was necessary long ago when lime-tech was storing a copy in that root- file, but in the 5.X series)

  • Author

Sorry for a delay. I think I finally found a reason why this was happening. My script was missing "exit" at the end. So it should be:

 

#! /bin/bash

/usr/bin/mysqldump -u root -ppassword --all-databases > /mnt/user/Backup/MySQL/dumps/mysql_backup__`date +%Y_%m_%d_%H_%M_%S`.sql

exit

 

Once I added it at the end, the job executes only once.

 

Attachement shows my crontab

 

I modfied script that adds new lines to crontab:

 

#! /bin/bash

crontab -l >/tmp/crontab

echo "# backup mysql at 11:30 AM" >>/tmp/crontab

echo "30 11 * * * /boot/custom/mysql_dump.sh 1> /dev/null" >>/tmp/crontab

echo "# tar mysql at 11:45 AM" >>/tmp/crontab

echo "45 11 * * * /boot/custom/mysql_tar.sh 1> /dev/null" >>/tmp/crontab

crontab /tmp/crontab

exit

 

Next I added a new line to "go" script to add new lines to crontab at boot up:

 

# add crontab jobs

/boot/custom/crontab_newline.sh

 

But when I checked crontab -l , additions were not there. Not sure what happened?

Running script from telnet works, and as you can see new lines are there.

crontab.png.e57d90fc0435014f81e997a5cc34c701.png

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.