March 15, 20224 yr Well you put me already on the right path. Checking with chromium works but my "daily" browser Firefox 91.7.0esr doesn't
March 17, 20224 yr Hi @Squid I just found out something weired and maybe of interest regarding the behaviour of the "User-Script" plugin. If I just regularly delete a script in the GUI, the script itself is being deleted in /boot/config/plugins/user.scripts but within the schedule.json file the scripts definitions from the deleted scripts are still there. (see picture in spoiler: the marked ones have been deleted before) Spoiler In fact, as long as the script-file itself does not exist any longer, it would not be a problem. But 1.) every time this schedule.json file is loaded by the plugin, it loads old, already unnecessary stuff. And 2.), going one step further, imagine what could happen if you create a script with the same name or the same file-name or if you create a script manually and put it into this directory with the same file name? Of course, all this may be a problem just in rare circumstances but in my opinion the file and config handling of plugins in such important systems like a NAS should be as correct as possible to prevent from unintended errors as good as possible. At this point, nevertheless, a *BIG* thank you for this plugin. It helps a lot! Regards DaKarli. 🤗
March 17, 20224 yr Author 2 hours ago, DaKarli said: But 1.) every time this schedule.json file is loaded by the plugin, it loads old, already unnecessary stuff. Yes that's correct. It was a design consideration to make everything a ton easier and also handle if the user manually deleted the scripts. The script execution engine checks for the existence of the script before executing to handle this. 2 hours ago, DaKarli said: And 2.), going one step further, imagine what could happen if you create a script with the same name or the same file-name or if you create a script manually and put it into this directory with the same file name? Then it should show up on the list with the same settings as the one previously deleted.
March 18, 20224 yr 21 hours ago, Squid said: Yes that's correct. It was a design consideration to make everything a ton easier and also handle if the user manually deleted the scripts. The script execution engine checks for the existence of the script before executing to handle this. Then it should show up on the list with the same settings as the one previously deleted. Ok, so if the script exec engine checks this before, like I said, it may be no problem. So it would be no problem either to manually delete old entries from the .json file if someone wants to go this extra step. Regarding your 2nd point, I just want to add that the risk is somewhere else. If you add a different script but with the same name, you may not be aware that this new script will be executed by the old line in the .json file right after you saved that file. But just as I already said, these may be rare circumstances and I just wanted point to possible risks with the handling being like it is. Cheers ! 😉
March 18, 20224 yr CA Backup/Restore Appdata does not see my script at /boot/config/plugins/user.scripts/scripts/. How can I path to custom start script in this use case? Do I need to save the script somewhere else the plugin can see?
March 20, 20224 yr Just a thought I had for a possible visual addition to this fantastic plugin. Highlighting when hovering over a script to more easily identify which script you are on when over in the far right like in the log section for example. Kind of like is implemented in the new Dynamix File Manager plugin, or how things are highlighted in the main and shares tabs of Unraid 6.10.0-rc4.
March 20, 20224 yr I have seen some scripts include "echo", "logger" and behind some commands they write 2>&1 >>[some adress to a log file], and a date command, what do they do? Any website I havent found yet that explains it? (might be searching for the wrong things) Edited March 20, 20224 yr by Mihle
March 20, 20224 yr 30 minutes ago, Mihle said: 2>&1 >>[ is so both standard output and standard errors are appended to the log file. Edited March 20, 20224 yr by SimonF
March 23, 20224 yr Trying to make a script I can run that backs stuff up to an unassigned devices HDD. #!/bin/bash #Destination of the backup: destination="/mnt/disks/OfflineBackup" #Name of Backup disk drive=dev1 ######################################################################## #Backup with docker containers stopped: #Stop Docker Containers echo 'Stopping Docker Containers' docker stop $(docker ps -a -q) #Backup Docker Appdata via rsync echo 'Making Backup of Appdata' rsync -avr --delete "/mnt/user/appdata" $destination #Backup Flash drive backup share via rsync echo 'Making Backup of Flash drive' rsync -avr --delete "/mnt/user/NAS Flash drive backup" $destination #Backup Nextcloud share via rsync echo 'Making Backup of Nextcloud' rsync -avr --delete "/mnt/user/NCloud" $destination #Start Docker Containers echo 'Starting up Docker Containers' /etc/rc.d/rc.docker start ######################################################################## #Backup of the other stuff: #Backup Game Backup share via rsync echo 'Making Backup Game Backup share' rsync -avr --delete "/mnt/user/Game Backups" $destination #Backup Photos and Videos share via rsync echo 'Making Backup of Photos and Videos share' rsync -avr --delete "/mnt/user/Photos and Videos" $destination ######################################################################## #Umount destination echo 'Unmounting and spinning down Disk....' /usr/local/sbin/rc.unassigned umount $drive /usr/local/sbin/rc.unassigned spindown $drive #Notify about backup complete /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Backup to Unassigned Disk" -d "A copy of important data has been backed up" -i "normal" echo 'Backup Complete' I am not sure if I should use echo or logger? Also, in a test script, I didnt manage to get the 2>&1 >> $LOGFILE that I see some use at the end of rsync commands to do anything, what does it do and should I try to get it to work? Some do >> var/log/[something].log (together with some date command) What do they do? For reference, I set the drive to automount, then I want to manually have to start the script, but when its done running I want to be ready to just unplug without having to press anything more. (and then take to another location until its time to update it) (offline backup)
March 24, 20224 yr Hi, I am trying to get custom schedule to work. I have a script to reindex a folder every 15 minutes every day from 6AM to 11PM. I put 0,15,30,45 6-23 * * * in the custom cron field but it never runs. Is this format supported by the plugin?
March 24, 20224 yr 13 minutes ago, aarontry said: Hi, I am trying to get custom schedule to work. I have a script to reindex a folder every 15 minutes every day from 6AM to 11PM. I put 0,15,30,45 6-23 * * * in the custom cron field but it never runs. Is this format supported by the plugin? Try */15 6-23 * * * I had a similar expression that would run a drive spin up every evening
March 25, 20224 yr 20 hours ago, Cessquill said: Try */15 6-23 * * * I had a similar expression that would run a drive spin up every evening Thanks! It works.
March 28, 20224 yr I have been searching the web about custom time schedules and cannot find exactly what I am looking for. If anyone can help me here that would be much appreciated. I need my script to run every 5 minutes every Sunday from 7:30a til 12 noon. Is this possible?
March 28, 20224 yr 16 minutes ago, arkestler said: I have been searching the web about custom time schedules and cannot find exactly what I am looking for. If anyone can help me here that would be much appreciated. I need my script to run every 5 minutes every Sunday from 7:30a til 12 noon. Is this possible? Just by tweaking the post above yours, this will get close: */5 7-12 * * 7 It should run every 5 minutes on a Sunday from 7-12, not 7.30. I'm not personally aware of any way to put fractions in to hour ranges (somebody else might know), but if it has to be from 7.30 onwards then you could tweak your script by putting a quick bit of logic at the start. Something like startTime="07:30" begin=$(date --date=$startTime +%s) now=$(date +%s) if [ "$now" -le "$begin" ]; then exit 1 fi ...would exit the script straight away for all times between 7 and 7.30. Haven't tested it though - just patched it from a script that I used to run before I realised custom schedules were a thing.
March 28, 20224 yr 2 hours ago, Cessquill said: Just by tweaking the post above yours, this will get close: */5 7-12 * * 7 It should run every 5 minutes on a Sunday from 7-12, not 7.30. I'm not personally aware of any way to put fractions in to hour ranges (somebody else might know), but if it has to be from 7.30 onwards then you could tweak your script by putting a quick bit of logic at the start. Something like startTime="07:30" begin=$(date --date=$startTime +%s) now=$(date +%s) if [ "$now" -le "$begin" ]; then exit 1 fi ...would exit the script straight away for all times between 7 and 7.30. Haven't tested it though - just patched it from a script that I used to run before I realised custom schedules were a thing. This is very helpful, thank you!
April 2, 20224 yr I have been looking for a document for an example on how to do this. I would like to set up a custom schedule within User Scripts to run every 2 days @ midnight. can someone please point me to the documentation, so that I can set this up please
April 2, 20224 yr 24 minutes ago, chris_netsmart said: can someone please point me to the documentation, so that I can set this up please so something like 0 0 */2 * * will run every 2nd day at midnight ... google will give you around 1 mio results in no time how to define cron timings, just try it and you will see it
April 5, 20224 yr There's a typo on the link to "What is Cron" on the /Settings/Userscripts page. It goes to corntab.com instead of crontab.com
April 5, 20224 yr 12 minutes ago, Teknishun said: There's a typo on the link to "What is Cron" on the /Settings/Userscripts page. It goes to corntab.com instead of crontab.com Did you try the link? corntab.com is the place I always go. crontab.com domain is for sale.
April 5, 20224 yr 4 minutes ago, trurl said: Did you try the link? Doesn't seem to be working for me at the moment though.
April 6, 20224 yr I'm still new to using the User Scripts plugin and still trying my best to learn a few tricks. I'm trying to move files (a folder with 1 file) from one location to another. For example: mv -f /mnt/user/Downloads/Completed/1.MOVIES/ /mnt/user/Media/Movies/Movies-6/ The above of course, moves the entire 1.MOVIES folder to the location Movies-6 I need it to move only whatever folder and file that appear in that folder - how do I do that? Thanks for any/all help!
April 6, 20224 yr 7 hours ago, trurl said: Doesn't seem to be working for me at the moment though. Maybe it should be changed to the wiki page. https://en.wikipedia.org/wiki/Cron
April 6, 20224 yr 9 hours ago, trurl said: Did you try the link? corntab.com is the place I always go. crontab.com domain is for sale. Huh, I'm sure I tried it last night but it was pretty late! My bad🤦
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.