morallydubious Posted December 17, 2020 Share Posted December 17, 2020 I maybe having a senior moment but my system restart script is my first attempt (that I remember) at a scheduled task in unraid. I suppose I could have tried a docker restart script in the distant past and it failed because I failed to RTFM and didn't correlate the name of the script in the GUI to the directory name. Not sure how I got better at diagnosing the issue this time around though 🙂 Any way this can serve as a cautionary tale to others Quote Link to comment
Squid Posted December 17, 2020 Author Share Posted December 17, 2020 IT's not entirely your fault. It's on a todo list to revamp the system to allow special characters in the names without crashing the software. It just takes a big rewrite though/ Quote Link to comment
morallydubious Posted December 17, 2020 Share Posted December 17, 2020 1 hour ago, Squid said: IT's not entirely your fault. It's on a todo list to revamp the system to allow special characters in the names without crashing the software. It just takes a big rewrite though/ Thanks Squid. It's a good plugin and I certainly appreciate the time and effort you are putting in. Quote Link to comment
axeman Posted December 18, 2020 Share Posted December 18, 2020 Hi there! Is there a way to control the order of execution on the "at Array First Start?" I have three scripts that I'd like two to run BEFORE the third one runs. Does it go by the script name or by what's in the #name variable? or something else? Quote Link to comment
Marshalleq Posted December 19, 2020 Share Posted December 19, 2020 (edited) Hey, anyone else experiencing non-responsive user scripts in rc1 of 6.9? I'm finding I can't edit one at all that I've just created, can't delete it etc either. On top of that I can't schedule any of the default ones. Haven't tried rebooting, but that seems a bit extreme. <<Edit>> Actually I think the script I added below was causing it (deleted manually at console), but oddly I didn't even get to run the script, just using the name below was enough so full stops or underscores? Seems unlikely. Either way, just renaming it to something basic got me going. Edited December 19, 2020 by Marshalleq Quote Link to comment
sunbear Posted December 22, 2020 Share Posted December 22, 2020 On 6/25/2016 at 3:41 PM, Squid said: Just a simple little plugin to act as a front end for any little scripts that you may have that you may need to run every once in a while, and don't feel like dropping down to the command line to do it. (Or anything that I happen to run across here on the forum that will be of use to some people) Install it via Community Applications Only a couple included scripts: - Delete .DS_Store files from the array - Delete any dangling images from the docker.img file - Display the size of the docker container's log files (to see if a docker app is filling up the image file through excessive logging) Additional Scripts from myself (and hopefully other users) can be found here: http://lime-technology.com/forum/index.php?topic=50416.0 To add your own scripts: Within the flash drive folder config/plugins/user.scripts/scripts create a new folder (each script is going to have its own folder) - The name doesn't matter but it can only contain the following characters: letters ([A-Za-z]), digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), periods ("."), and spaces (" ") Or, you can hit the button that says "Add Script", then give the script a name. Hovering over the script's name will then give you additional options. Including online editing... Create a file called description that contains the description of the script. Create a file called script this will be the actual script. Few notes: So as to make things easier for people: The script file can be created with any text editor you choose. DOS line endings will be automatically converted to Linux style endings prior to execution. #!bin/bash is automatically added to every script prior to execution to help out the noobies EDIT: This is only added if no interpreter is specified (ie: #!/bin/bash) If an interpreter is already specified (ie: #!/usr/bin/php), then line is not added Various aspects of the scripts are controlled through variables contained within the scripts themselves. This includes the description, if they can run in the background, etc. See this post: http://lime-technology.com/forum/index.php?topic=49992.msg516885#msg516885 for more details Techie Notes: The scripts are actually copied and executed from /usr/local/emhttp/plugins/user.scripts/ /tmp/user.scripts/tmpScripts so if there are dependencies (other scripts, etc) stored in the same folder as the script file, you will need to specify the full path to them. Interactive (ie: answering yes/no to a question) scripts will not work. Is there anyway I can remove the description and path rows from the USERSCRIPTS GUI page? After having a reasonable amount of scripts it gets pretty tough to have to scroll and find the script you're looking for. Having just a list of the script names would help a bit. Or if there was any way to provide some structure or add folders, it would make it much easier for me to use this plugin. Quote Link to comment
Hedout Posted December 22, 2020 Share Posted December 22, 2020 I wrote a script to control the fan speed through IPMI and would like it to run at 1 min intervals. I have tested that the code runs no problem when I click on "RUN SCRIPTS" or "RUN IN BACKGROUND", however, the cron scheduling doesn't seem to work. I check the log and it doesn't show this script being executed every minute. The log does show the script executed manually when I click on "RUN SCRIPTS". Anything I can do to make sure the script runs? Quote Link to comment
Squid Posted December 22, 2020 Author Share Posted December 22, 2020 9 hours ago, Hedout said: I wrote a script to control the fan speed through IPMI and would like it to run at 1 min intervals. I have tested that the code runs no problem when I click on "RUN SCRIPTS" or "RUN IN BACKGROUND", however, the cron scheduling doesn't seem to work. I check the log and it doesn't show this script being executed every minute. The log does show the script executed manually when I click on "RUN SCRIPTS". Anything I can do to make sure the script runs? 1 * * * * means to run at the first minute of every hour, every day etc. You want * * * * * Quote Link to comment
adminmat Posted December 26, 2020 Share Posted December 26, 2020 This is my first User Script. I just want to back up a share that's on a single SSD Pool drive that contains my Nextcloud data to my array. (not appData. That's on my cache) Does this look OK? I got it from @hernandito . Thanks. #!/bin/bash source="/mnt/user/nextcloud/" destination="/mnt/user/backups/nextcloud-backup" echo "<div style=' width: 40%; -webkit-border-radius: 8px 8px 0 0; border-radius: 8px 8px 0 0; border: solid 1px #cccccc; background-color: #ffe88a; padding-left: 10px;'><br><b><font color='black' size='2'>Backing-Up Nextcloud Folder </font><b><br> </div>" #echo "=======================" #echo "Backing-up from:" #echo " <b><font color='blue'>"$source "</b></font>" #echo "to:" #echo " <b><font color='blue'>"$destination </b></font>" echo "<div style='width: 40%; -webkit-border-radius: 0 0 8px 8px; border-radius: 0 0 8px 8px; background-color: #ebebeb; margin-top: -14px; padding-left: 10px; padding-top: 6px;border: solid 1px #cccccc; '>Backing-up from: <br><b><font color='blue' size='2'>"$source "</b></font> <br>to:<br><b><font color='blue' size='2'>"$destination "</b></font><br> </div>" date >/var/log/cache_backup.log /usr/bin/rsync -avrtH --delete $source $destination >>/var/log/nextcloud_backup.log echo "" echo "<div style='padding-left: 10px; margin-top: -14px; '><font color='green' size='4'><b>Done!</b></font></div>"ft: 10px; margin-top: -14px; '><font color='green' size='4'><b>Done!</b></font></div>" Quote Link to comment
Stupifier Posted December 30, 2020 Share Posted December 30, 2020 On 12/7/2020 at 2:27 PM, Stupifier said: How do I run any CA Userscript Script from within a Terminal Session? I know copies of scripts are held and ran from " /tmp/user.scripts/tmpScripts"....but when I go there via Terminal...I don't see ALL of my scripts listed (only a subset). It appears the only scripts listed here are ones which have been previously executed through Userscripts GUI. I know scripts are also located in "/boot/config/plugins/user.scripts/scripts" but those are all buttoned up with permissions restricting run (probably for good reason too since its the flash drive). Any help at all regarding this.....Sometimes its just plain easier for me to run stuff from a terminal instead of the unraid GUI....and I'd rather not clone all of my userscripts to another location just so I can run them via terminal. But if that's how its gotta be....ok.... Quote Link to comment
itimpi Posted December 31, 2020 Share Posted December 31, 2020 9 hours ago, Stupifier said: Any help at all regarding this.....Sometimes its just plain easier for me to run stuff from a terminal instead of the unraid GUI....and I'd rather not clone all of my userscripts to another location just so I can run them via terminal. But if that's how its gotta be....ok.... If you want to run scripts that are on the flash drive without first copying them elsewhere then use something like ‘sh path-to-script’. This gets around the fact that scripts on the flash drive cannot be given execute permission so they can be executed directly. 1 Quote Link to comment
HarryD Posted January 1, 2021 Share Posted January 1, 2021 My issue is that i have a script i need to run scheduled in the background test.sh. If i run the scripts from the userscripts page with the "run script" button it works with no issue. However when i click "run in background" the script does not run, i have deleted the plugin and deleted it from the drive also, then reinstalled. I have a second unraid server with an identical script that runs flawlessly and now even the default scripts do not action. below is the server log when i click "run script" and nothing happens Jan 2 04:50:20 Email emhttpd: cmd: /usr/local/emhttp/plugins/user.scripts/backgroundScript.sh /tmp/user.scripts/tmpScripts/test/script any help would be greatly appreciated. Quote Link to comment
Squid Posted January 1, 2021 Author Share Posted January 1, 2021 3 minutes ago, HarryD said: My issue is that i have a script i need to run scheduled in the background test.sh. If i run the scripts from the userscripts page with the "run script" button it works with no issue. However when i click "run in background" the script does not run, i have deleted the plugin and deleted it from the drive also, then reinstalled. I have a second unraid server with an identical script that runs flawlessly and now even the default scripts do not action. below is the server log when i click "run script" and nothing happens Jan 2 04:50:20 Email emhttpd: cmd: /usr/local/emhttp/plugins/user.scripts/backgroundScript.sh /tmp/user.scripts/tmpScripts/test/script any help would be greatly appreciated. Any punctuation in the description? Quote Link to comment
HarryD Posted January 1, 2021 Share Posted January 1, 2021 3 minutes ago, Squid said: Any punctuation in the description? i might miss-understand what you're saying? sorry if my original post was not clear. When i attempt to run the script in the image below, clicking the "Run in background" button, nothing happens. script is identical to the one i use on another unraid server without issues. however even the default scripts that come with the 'userscripts' plugin do not run in background. Quote Link to comment
Squid Posted January 1, 2021 Author Share Posted January 1, 2021 Give me a screenshot then of the entire page Quote Link to comment
HarryD Posted January 1, 2021 Share Posted January 1, 2021 (edited) 3 minutes ago, Squid said: Give me a screenshot then of the entire page full page screenshot, brings up "script running window" as normal but script does not actually run in background and doesn't bring up the usual "running" Edited January 1, 2021 by HarryD Quote Link to comment
sdfyjert Posted January 6, 2021 Share Posted January 6, 2021 (edited) I am trying to run some command and push them the in background but the GUI terminal seems to get stuck and the script doesn't really seem to finish (I do not see the echo in the window and running ps aux | grep avahi-publish show the process does not exist). Any suggestions? #!/bin/bash #description=Generate avahi aliases #foregroundOnly=true #name=Avahi aliases (sub-domains) echo "plex.inas.local" /usr/bin/avahi-publish -a -R plex.inas.local $(avahi-resolve -4 -n inas.local | cut -f 2) & Edited January 6, 2021 by sdfyjert Quote Link to comment
Squid Posted January 6, 2021 Author Share Posted January 6, 2021 I would try the "at" command (at NOW -m IIRC) to start your process Quote Link to comment
kizer Posted January 6, 2021 Share Posted January 6, 2021 On 1/1/2021 at 1:33 PM, HarryD said: full page screenshot, brings up "script running window" as normal but script does not actually run in background and doesn't bring up the usual "running" From what I remember that's normal. Otherwise there would be an error saying. If you close this box it will shut down the script. Simply click the close button it will continue running in the background. Quote Link to comment
NewDisplayName Posted January 6, 2021 Share Posted January 6, 2021 Is there a easy way to pause all scripts? (if not i suggest a pause unpause button switch) Quote Link to comment
Fffrank Posted January 6, 2021 Share Posted January 6, 2021 Trying to run a script that deletes all folders under a certain size (which works perfectly) but I need to exclude 1 folder and I can't get the syntax right. Help? #!/bin/bash shopt -s extglob du /mnt/user/media/Movies/ | awk '$1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"}' | sh awk: cmd. line:1: $1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"} awk: cmd. line:1: ^ syntax error Quote Link to comment
Fffrank Posted January 6, 2021 Share Posted January 6, 2021 5 hours ago, Fffrank said: Trying to run a script that deletes all folders under a certain size (which works perfectly) but I need to exclude 1 folder and I can't get the syntax right. Help? #!/bin/bash shopt -s extglob du /mnt/user/media/Movies/ | awk '$1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"}' | sh awk: cmd. line:1: $1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"} awk: cmd. line:1: ^ syntax error Solved my own problem and wanted to post the solution. I added the if statement for exclusion to the awk routine rather than asking asking the rm command to ignore. du /mnt/user/media/Movies/ | awk '{ if ( $1 <= 300000 && $2 != "/mnt/user/media/Movies/.stfolder" ) print "rm -rf -v \"" substr($0, length($1)+2) "\"" }' | sh Quote Link to comment
Lonnie LeMaster Posted January 17, 2021 Share Posted January 17, 2021 Is there a way to schedule a script to run at the conclusion of another? Quote Link to comment
Aerodb Posted January 18, 2021 Share Posted January 18, 2021 So, I'm having some issues with a docker... those issues aside, I'm looking for a script to schedule a docker reboot regularly, such as every 2 hours or so. I have been working to resolve the core issue but thus far, the only resolution I have found is to restart the problem docker. anyone have a script that can accomplish this? Quote Link to comment
JonathanM Posted January 18, 2021 Share Posted January 18, 2021 2 hours ago, Aerodb said: I'm looking for a script to schedule a docker reboot regularly, such as every 2 hours or so. https://forums.unraid.net/topic/44140-support-binhex-nzbget/?do=findComment&comment=834897 Adapt as needed. 1 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.