batesman73 Posted March 15, 2022 Share Posted March 15, 2022 Hi, after upgrading to 6.10-rc3 I can't edit scripts any more via the WebIF. Even though i create a new one I could only enter the name of the script but no "content". Does anybody know about it ? The scripts themselves are still existing and I can edit via ssh/nano. HTX Quote Link to comment
Squid Posted March 15, 2022 Author Share Posted March 15, 2022 Works for me. Not sure. What browser? Quote Link to comment
batesman73 Posted March 15, 2022 Share Posted March 15, 2022 Well you put me already on the right path. Checking with chromium works but my "daily" browser Firefox 91.7.0esr doesn't Quote Link to comment
Squid Posted March 15, 2022 Author Share Posted March 15, 2022 Firefox 98.0.1 also works for me. Quote Link to comment
DaKarli Posted March 17, 2022 Share Posted March 17, 2022 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. 🤗 Quote Link to comment
Squid Posted March 17, 2022 Author Share Posted March 17, 2022 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. Quote Link to comment
DaKarli Posted March 18, 2022 Share Posted March 18, 2022 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 ! 😉 Quote Link to comment
Bulletoverload Posted March 18, 2022 Share Posted March 18, 2022 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? Quote Link to comment
MadMatt337 Posted March 20, 2022 Share Posted March 20, 2022 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. Quote Link to comment
Mihle Posted March 20, 2022 Share Posted March 20, 2022 (edited) 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, 2022 by Mihle Quote Link to comment
SimonF Posted March 20, 2022 Share Posted March 20, 2022 (edited) 30 minutes ago, Mihle said: 2>&1 >>[ is so both standard output and standard errors are appended to the log file. Edited March 20, 2022 by SimonF Quote Link to comment
Mihle Posted March 23, 2022 Share Posted March 23, 2022 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) Quote Link to comment
aarontry Posted March 24, 2022 Share Posted March 24, 2022 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? Quote Link to comment
Cessquill Posted March 24, 2022 Share Posted March 24, 2022 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 Quote Link to comment
aarontry Posted March 25, 2022 Share Posted March 25, 2022 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. Quote Link to comment
arkestler Posted March 28, 2022 Share Posted March 28, 2022 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? Quote Link to comment
Cessquill Posted March 28, 2022 Share Posted March 28, 2022 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. Quote Link to comment
arkestler Posted March 28, 2022 Share Posted March 28, 2022 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! Quote Link to comment
chris_netsmart Posted April 2, 2022 Share Posted April 2, 2022 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 Quote Link to comment
alturismo Posted April 2, 2022 Share Posted April 2, 2022 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 1 Quote Link to comment
Teknishun Posted April 5, 2022 Share Posted April 5, 2022 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 Quote Link to comment
trurl Posted April 5, 2022 Share Posted April 5, 2022 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. Quote Link to comment
trurl Posted April 5, 2022 Share Posted April 5, 2022 4 minutes ago, trurl said: Did you try the link? Doesn't seem to be working for me at the moment though. Quote Link to comment
MONSTER_MIKE Posted April 6, 2022 Share Posted April 6, 2022 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! Quote Link to comment
SimonF Posted April 6, 2022 Share Posted April 6, 2022 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 Quote Link to comment
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.