November 22, 201510 yr I have added a cron job using my go script: # Add Cron job to run YAMJ once per day printf '#\n# Scheduled YAMJ Scan at Midnight every day:\n00 00 * * * /mnt/APPS/YAMJ/unRAID.sh > /dev/null 2>&1\n' >> /var/spool/cron/crontabs/root And here is crontab -l : # If you don't want the output of a cron job mailed to you, you have to direct # any output to /dev/null. We'll do this here since these jobs should run # properly on a newly installed system. If a script fails, run-parts will # mail a notice to root. # # Run the hourly, daily, weekly, and monthly cron jobs. # Jobs that need different timing may be entered into the crontab as before, # but most really don't need greater granularity than this. If the exact # times of the hourly, daily, weekly, and monthly cron jobs do not suit your # needs, feel free to adjust them. # # Run hourly cron jobs at 47 minutes after the hour: 47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null # # Run daily cron jobs at 4:40 every day: 40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null # # Run weekly cron jobs at 4:30 on the first day of the week: 30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null # # Run monthly cron jobs at 4:20 on the first day of the month: 20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null # # Scheduled YAMJ Scan at Midnight every day: 00 00 * * * /mnt/APPS/YAMJ/unRAID.sh > /dev/null 2>&1 I verified the unRAID.sh script works by running it manually. I got the crontab to work by stopping and starting cron. crond stop crond start However, after a reboot, my added cron does not run. What is going on? Or, not going on?
November 22, 201510 yr I just had a similar problem with things not working after reboot but working manually. Check this thread out and see if it helps... http://lime-technology.com/forum/index.php?topic=42024.new;topicseen#new
November 22, 201510 yr Appending entries to via >> /var/spool/cron/crontabs/root is not the normal way it is done. details deleted since there is a better dynamix way...
November 23, 201510 yr Community Expert You can put a .cron file anywhere under /boot/config/plugins/dynamix and it will be added to crontab for you when you boot. See some of the built-in .cron files there for examples.
November 23, 201510 yr Author You can put a .cron file anywhere under /boot/config/plugins/dynamix and it will be added to crontab for you when you boot. See some of the built-in .cron files there for examples. Is there another script I need to run i.e. "update_cron"? I do not see any .cron files under /boot/config/plugins/dynamix. Can you send a sample .cron file?
November 23, 201510 yr In unRAID v6 it is made much simpler to add custom cron entries. Create a folder on your flash device under plugins, e.g. /boot/config/plugins/mycron In this folder you can put one or more cron files. Choose an appropriate name and give the file the extension .cron The file content is a cron entry and it uses linux style line endings (make sure you use an editor which can do that, e.g. notepad++) For example the file localmaster.cron has the following: # Generated local master browser check: */1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/localmaster &> /dev/null This starts the script "localmaster" every minute. Note that scripts don't have to be under the dynamix folder, you can create your own folder (can be on flash too) and point to it. Upon system reboot ALL .cron files are automatically loaded in the cronjob. You can also do a manual load by telnetting into your system and perform: update_cron
November 23, 201510 yr In unRAID v6 it is made much simpler to add custom cron entries. Create a folder on your flash device under plugins, e.g. /boot/config/plugins/mycron In this folder you can put one or more cron files. Choose an appropriate name and give the file the extension .cron The file content is a cron entry and it uses linux style line endings (make sure you use an editor which can do that, e.g. notepad++) For example the file localmaster.cron has the following: # Generated local master browser check: */1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/localmaster &> /dev/null This starts the script "localmaster" every minute. Note that scripts don't have to be under the dynamix folder, you can create your own folder (can be on flash too) and point to it. Upon system reboot ALL .cron files are automatically loaded in the cronjob. You can also do a manual load by telnetting into your system and perform: update_cron This is awesome! I just setup a cron job to run a custom script. Question: I currently have it set to run my script every 10 mins and the script lives on my flash drive. Is that going to cause extra wear and tear on the flash drive or is it fine? I could move the script to different location once the server boots if that is recommended?
November 23, 201510 yr Reading a file from the flash drive, won't introduce additional wear and tear (unRAID itself is also reading regularly settings from the flash drive).
November 23, 201510 yr Reading a file from the flash drive, won't introduce additional wear and tear (unRAID itself is also reading regularly settings from the flash drive). That's what I was thinking but figured it's best to make sure. Thanks!
December 1, 201510 yr Author You can put a .cron file anywhere under /boot/config/plugins/dynamix and it will be added to crontab for you when you boot. See some of the built-in .cron files there for examples. The cron file needs to be in the format: # Remark actual cron line <return> # Scheduled YAMJ Scan at Midnight every day: 0 0 * * * /mnt/APPS/YAMJ/unRAID.sh > /dev/null 2>&1
January 16, 201610 yr I've added a new .cron file to /boot/plugins/mycron and rebooted my server, but I don't see anything listed under crontab -l. Is this method not reflected here? How can I confirm my changes are updating properly (other than just waiting for the script to run)
January 17, 201610 yr I've added a new .cron file to /boot/plugins/mycron and rebooted my server, but I don't see anything listed under crontab -l. Is this method not reflected here? How can I confirm my changes are updating properly (other than just waiting for the script to run) cat /etc/cron.d/root
January 28, 201610 yr is "mycron" an actual plugin or just a directory that unraid picks up on its own?
January 29, 201610 yr Community Expert is "mycron" an actual plugin or just a directory that unraid picks up on its own? It's just an example. Any .cron file under the plugins folder or subfolders will get added. Create one and name it whatever or just put it in one that's already there.
January 29, 201610 yr is "mycron" an actual plugin or just a directory that unraid picks up on its own? It's just an example. Any .cron file under the plugins folder or subfolders will get added. Create one and name it whatever or just put it in one that's already there. Jackpot! I've been looking for a plugin all day that will install a cron for me!
January 29, 201610 yr I have added 15 00 * * * /usr/bin/rsnapshot -c /etc/rsnapshot.conf hourly 15 02 * * * /usr/bin/rsnapshot -c /etc/rsnapshot.conf daily 15 03 * * Sun /usr/bin/rsnapshot -c /etc/rsnapshot.conf weekly 30 03 1 * * /usr/bin/rsnapshot -c /etc/rsnapshot.conf monthly /boot/config/plugins/rsnapshot.cron and nothing gets added to /etc/cron.d/root Thoughts?
January 31, 201610 yr I have added 15 00 * * * /usr/bin/rsnapshot -c /etc/rsnapshot.conf hourly 15 02 * * * /usr/bin/rsnapshot -c /etc/rsnapshot.conf daily 15 03 * * Sun /usr/bin/rsnapshot -c /etc/rsnapshot.conf weekly 30 03 1 * * /usr/bin/rsnapshot -c /etc/rsnapshot.conf monthly /boot/config/plugins/rsnapshot.cron and nothing gets added to /etc/cron.d/root Thoughts? You need to place the .cron file in a sub-directory. E.g /boot/config/plugins/rsnapshot/rsnapshot.cron
March 23, 20188 yr Sorry to resurrect an old thread. I have been using the above method for cron jobs for a number of years successfully. On Feb 23, cron jobs stopped running that I've set up in the /boot/config/plugins/mycron folder. The cron jobs are inside a file called bkp.cron. The cron jobs in the file are all rsyncs that I use to back up primary data to a secondary location. The cron jobs stopped working around the time I moved from 6.4 to 6.5. I haven't downgraded to test if an earlier version works yet. It's a production environment and I don't want to take it offline unless I have to. Upgrading to the latest version of Unraid, 6.5.1-rc1, hasn't resolved the issue. Has anyone else experienced this? I've attached diags. luna-diagnostics-20180323-0854.zip
March 23, 20188 yr Starting with unRAID 6.4 it is no longer allowed to store cron jobs in arbritary folders. unRAID will look only for folders created by plugins. Anything none plugin related and you want to run can be placed under /config/plugins/dynamix.
April 1, 20188 yr Just wanted to say I had the same issue. Updated a couple days ago to 6.5.0 and my script stopped getting scheduled. I had it under /boot/plugins/mycron/myscript.cron and the file looked like: #will need to call command `update_cron` to load these in without reboot * * * * * /boot/myScripts/hdStats.php &> /dev/null I moved it to /boot/plugins/dynamix/myscript.cron. After running update_cron it showed up in /etc/cron.d/root just like it used to. Thanks for the tip!
November 6, 20187 yr I have been trying to get entries added to crontab without success. Using the procedure in the above post, I created a file named: /boot/config/plugins/dynamix/my_cron.cron which contains: # run backup script on Home\ Video to copy to Backup1 every Sunday at 4am 0 4 * * 0 /boot/config/my_scripts/backup_home_video.sh # run script to list individual disk contents 0 4 * * 0 /boot/config/my_scripts/list_disks.sh I ran update_cron and these entries do indeed get added to /etc/cron.d/root Here are the contents of /etc/cron.d/root: root@Tower:/boot/config/plugins/dynamix# cat /etc/cron.d/root # Generated docker monitoring schedule: 10 0 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate.php check &> /dev/null # Generated system monitoring schedule: */1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null # Generated mover schedule: 40 3 * * * /usr/local/sbin/mover &> /dev/null # run backup script on Home\ Video to copy to Backup1 every Sunday at 4am 0 4 * * 0 /boot/config/my_scripts/backup_home_video.sh # run script to list individual disk contents 0 4 * * 0 /boot/config/my_scripts/list_disks.sh # Generated parity check schedule: 0 0 1 * * /usr/local/sbin/mdcmd check &> /dev/null || : # Generated plugins version check schedule: 10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null # Generated array status check schedule: 20 0 * * * /usr/local/emhttp/plugins/dynamix/scripts/statuscheck &> /dev/null # Generated unRAID OS update check schedule: 11 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null # Generated cron settings for plugin autoupdates 0 0 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1 # Generated local master browser check: */1 * * * * /usr/local/emhttp/plugins/dynamix.local.master/scripts/localmaster &> /dev/null # Generated ssd trim schedule: 0 0 * * * /sbin/fstrim -a -v | logger &> /dev/null # Generated system data collection schedule: */1 * * * * /usr/local/emhttp/plugins/dynamix.system.stats/scripts/sa1 1 1 &>/dev/null however, when I run crontab -l, the entries do not show up and the commands are not run at the appointed time. Here is the output of crontab -l: # If you don't want the output of a cron job mailed to you, you have to direct # any output to /dev/null. We'll do this here since these jobs should run # properly on a newly installed system. If a script fails, run-parts will # mail a notice to root. # # Run the hourly, daily, weekly, and monthly cron jobs. # Jobs that need different timing may be entered into the crontab as before, # but most really don't need greater granularity than this. If the exact # times of the hourly, daily, weekly, and monthly cron jobs do not suit your # needs, feel free to adjust them. # # Run hourly cron jobs at 47 minutes after the hour: 47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null # # Run daily cron jobs at 4:40 every day: 40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null # # Run weekly cron jobs at 4:30 on the first day of the week: 30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null # # Run monthly cron jobs at 4:20 on the first day of the month: 20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null 0 3 * * * /usr/local/emhttp/plugins/ca.backup2/scripts/backup.php &>/dev/null 2>&1 My understanding is that this is the crontab that is running and, indeed, my scripts are not being run. So the question is: how to get the entries in the active crontab and have them re-inserted at boot time?
March 6, 20215 yr On 4/1/2018 at 7:03 PM, kubed_zero said: #will need to call command `update_cron` to load these in without reboot * * * * * /boot/myScripts/hdStats.php &> /dev/null I moved it to /boot/plugins/dynamix/myscript.cron. After running update_cron it showed up in /etc/cron.d/root just like it used to. From /usr/local/sbin/update_cron you can see all *.cron within dynamix are gathered (Unraid 6.9.0) cat /boot/config/plugins/dynamix/*.cron 2>/dev/null
Archived
This topic is now archived and is closed to further replies.