Daburgers Posted September 9, 2024 Posted September 9, 2024 (edited) Hi All, I am having an issue where my user scripts will not work/run ONLY when using a custom cron schedule. I only have 3 scripts. An antivirus script, clear drive script and a simple script to power down the server. I first tried setting a custom cron schedule for the antivirus script, but nothing would happen. However, the script runs fine in the foreground, background, and by using the pre-defined schedule options (ie. at stopping of array, schedule hourly etc). So I made a new simple script to power down the server and it too would do nothing when I had a custom cron schedule set. The script to power down the server contains the following: #!/bin/bash powerdown I set the custom cron schedule to: 0 9 * * * (9am every every day - I did try different times as well....9:05am, 11:30am - 5 9 * * * , 30 11 * * * , etc) Nothing happens and no log recorded. To state the obvious, I made sure to set it at a time a well ahead of the current time, no joy! However, when I click 'run script', 'run in background', or using the pre-defined schedule (I used 'at stopping of array' for testing), the script ran each time without an issue and the device powered down accordingly. A log was created as well. I have attached the unraid logs in case that helps. Appreciate any assistance that anyone can offer! When reading through the forums on this kind of issue, someone with a somewhat similar issue was advised to run a couple of commands which may help find out what's going on, although I am not sure what to look for. I thought I'd include them in case it helps as well. Please see below: root@Tower:~# 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 8 9 * * * /usr/local/emhttp/plugins/nvidia-driver/include/update-check.sh &>/dev/null 2>&1 # Job for VM Backup plugin default: 0 3 * * 0 /usr/local/emhttp/plugins/vmbackup/runscript.php run_backup default > /dev/null 2>&1 root@Tower:~# cat /etc/cron.d/root # Generated docker monitoring schedule: 10 0 * * 1 /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check &> /dev/null # Generated system monitoring schedule: */1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null # Generated mover schedule: 0 0 1 * * /usr/local/sbin/mover &> /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 docker autoupdates 0 0 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1 # Generated cron settings for plugin autoupdates 0 0 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1 # CRON for CA background scanning of applications 57 * * * * php /usr/local/emhttp/plugins/community.applications/scripts/notices.php > /dev/null 2>&1 # Generated system data collection schedule: */1 * * * * /usr/local/emhttp/plugins/dynamix.system.stats/scripts/sa1 1 1 &> /dev/null # Generated cron schedule for user.scripts 0 9 * * * /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/powerdown/script > /dev/null 2>&1 tower-diagnostics-20240909-0934.zip Edited September 9, 2024 by Daburgers provided more clarity and context Quote
JonathanM Posted September 9, 2024 Posted September 9, 2024 3 hours ago, Daburgers said: I am having an issue where my user scripts Try looking through the support thread for the User Scripts plugin, if the question is not already answered post there. Quote
Daburgers Posted September 9, 2024 Author Posted September 9, 2024 I probably should have posted this in that thread tbh! Thanks for sharing. I did find a fair few people with the same issue. Most didn't have provide an update as to if it worked or not. I assume they either forgot about it or gave up. This image below I also ran the same command I added in my first post. I can see the last line shows my cron line added. "until it runs you won't see anything". Not sure if this person had a different issue or the same issue but not explained properly. For me, I set the time to 9:00am. It would have been 8:45am at the time of setting the schedule up. At 9am, nothing happens. This one seems to be just a question. I assume they were having a similar issue as me but didn't go into detail or also forgot. Not sure: This is exactly thew issue I am having. I have it set exactly as this, but does not work. Unfortunately, I wasn't able to see if they managed to get it to work: Nevertheless, I will submit this question in that thread since it is specific to that plugin. Thanks again for sharing the link! Quote
Solution Daburgers Posted September 14, 2024 Author Solution Posted September 14, 2024 I managed to resolve the issue. For those who come across with the same issue, the issue was that the system time in unraid was incorrect - even though I had manually set it correctly. What happened was I noticed my server was actually powering down, but not at the right time. So that made me think it has to be my date & time settings. So I checked them again for the 4th time, and this is when I noticed the issue. The Time & Date were manually set, and correctly, but for some strange reason the "New date & time" at the bottom of the settings was not correct. So I decided to use NTP servers to see if that made any difference....and it did! The time adjusted correctly! I tested out my script again with a new schedule and BOOM - it worked! Attached is an image of my settings before and after I made the changes: 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.