Derek_ Posted September 26, 2020 Share Posted September 26, 2020 On 9/17/2020 at 4:55 AM, cmarshall85 said: @Derek_ did you ever figure this out? I am having the same issue. When I run lftp, any folders/files it creates are root:root and i need it to be nobody:users. Thanks! Hiya, sorry it's taken so long to reply. No - i never figured it out. I just accepted it as it was. As someone mentions, you can chown it after operations are complete if that works for your scenario. Quote Link to comment
54tgedrg45 Posted October 3, 2020 Share Posted October 3, 2020 (edited) Eum, where are the script output logs stored? after execution(of all scripts) I get the trashcan to delete log icon/prompt to delete log of task name, not informing path of log. How to view them? No idea where it would be. at flash /logs it shows none. Edit: OK, they can be found at /tmp/user.scripts/tmpScripts/ # logfile log.txt Edited October 3, 2020 by 54tgedrg45 Quote Link to comment
mgutt Posted October 3, 2020 Share Posted October 3, 2020 2 hours ago, 54tgedrg45 said: Eum, where are the script output logs stored? There aren't any. The logs are buggy so I used this at the beginning of all my scripts: # logging exec > >(tee --append --ignore-interrupts $(dirname ${0})/log.txt) 2>&1 By that all output is twice in the logs, but this was the only solution that worked. And only to inform you. There is another bug. Its not possible to stop scripts although the dashboard claims it. It seems @Squiddid not found the time to correct it. I posted two ways to solve it. Quote Link to comment
jowi Posted October 3, 2020 Share Posted October 3, 2020 (edited) User scripts has grown from a quickly bolted together handy but buggy tool into a substantial part of unraid that a lot of users have use for, and it needs and deserves a lot of rework and refactoring and attention to take it to a higher level. Edited October 3, 2020 by jowi Quote Link to comment
JonathanM Posted October 3, 2020 Share Posted October 3, 2020 3 minutes ago, jowi said: it needs and deserves a lot of rework and refactoring and attention are you volunteering your time and expertise? Quote Link to comment
jowi Posted October 3, 2020 Share Posted October 3, 2020 (edited) Yes, if i had the expertise. I can do c# .net core etc programming and some minor python, but somehow i think that is not needed here. Also linux is not my thing. If you’re suggesting i am not allowed to comment unless i contribute? F*** you. That is not up to you. Edited October 3, 2020 by jowi Quote Link to comment
Squid Posted October 3, 2020 Author Share Posted October 3, 2020 5 hours ago, mgutt said: The logs are buggy The logs are everything that is output by the script. And there's a download button that grabs them. Other things This is going to come across as a bit bitchy, but I truly don't mean anything by it. This plugin was simply designed to run a quick and dirty script here and there. It has definitely morphed into something else. And yes there are issues with Certain script naming will crash the plugin Sub processes spawned off of the initial script have issues being stopped Priorities are everything. While I do understand and appreciate the comments and suggestions, time doesn't always play along with supporting of code changes (or as probably needed here a complete rewrite of the plugin - which isn't an inconsequential time investment) and/or fixes. My priorities are as follows: CA, application feed, related items. They trump everything else Actual real-world work Fix Common Problems (Any false positives that may pop up as new versions of Unraid are released) Unraid GUI bug fixes etc Alexander Keith's Dogs Sleep Family Doom (Hopefully the wife doesn't read this , but that order does keep me sane) So far as time permitting after all of that, the priorities that I see plugin related (time permitting) are Autoupdate. I've noticed some oddities that I'm not sure if its a bug or not and need to investigate Backup / Restore - restart order doesn't match what's been utilized in the docker tab Cleanup Appdata - needs a big revamp to make it functionally work without probable timeouts happening if/when the deletions take more than 120 seconds Backup / Restore - Longstanding req to separate the archives by folder, and selectively restore them This plugin lags behind because it still is 100% functional within its original design considerations. Problem with it is that the code is ancient, and a rewrite is basically required to bring it into line with everything else, and make it maintainable. Unfortunately due to priority #2, my time is extremely limited until Christmas, and what time I do have may be filled up with priority #5 when the situation may change. I will get to it. I, like everyone else around here am a volunteer. In the meantime if anyone has any PRs, then they will get merged after testing. Quote Link to comment
mgutt Posted October 3, 2020 Share Posted October 3, 2020 3 hours ago, Squid said: The logs are everything that is output by the script. And there's a download button that grabs them. No. Does not work. echo "bla" is not logged. No verbose output is logged. Only fatal errors are logged. This is the reason why so many people complain and ask for the "real download" Quote Link to comment
54tgedrg45 Posted October 3, 2020 Share Posted October 3, 2020 I was searching for the path of the logs since there is no download button that grabs them. I'm now thinking of putting all output together with the rsync log file at backup destination. Quote Link to comment
mgutt Posted October 5, 2020 Share Posted October 5, 2020 On 10/4/2020 at 12:00 AM, mgutt said: No. Does not work. echo "bla" is not logged. I have to correct myself. It seems a recent version has solved this issue, as my logs are now working without my solution. Quote Link to comment
je82 Posted October 7, 2020 Share Posted October 7, 2020 (edited) scripts ran by user scripts plugin are they run as root user? edit: is there a way to run the script as a specific user? Edited October 7, 2020 by je82 Quote Link to comment
MJFox Posted October 13, 2020 Share Posted October 13, 2020 Hi! Great little plugin, thanks a lot. I have a question though: I want to start a script that runs in background after the disk array starts. This is the content of the script: #!/bin/bash tail -F "/mnt/cache/appdata/plex/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log" | \ while read line ; do echo "$line" | grep "authenticated user" if [ $? = 0 ] then mdcmd spinup 0 mdcmd spinup 1 mdcmd spinup 2 sleep 30 fi done what it does is it spins up the disks whenever somebody opens plex obviously I want to keep the script running in the background when unraid boots up... is it ok to just start the script with the "At Startup of Array"- option? will it keep running in the background then? thanks MJFox Quote Link to comment
Cessquill Posted October 13, 2020 Share Posted October 13, 2020 10 minutes ago, MJFOx said: This is the content of the script: Hopefully somebody else can answer your actual question, but as a side thought you could replace... mdcmd spinup 0 mdcmd spinup 1 mdcmd spinup 2 ...with... disks=$(ls /dev/md* | sed "sX/dev/mdXX"); for disknum in $disks; do /usr/local/sbin/mdcmd spinup $disknum; done I currently run this on a CRON schedule every 10 minutes between 19:00 and 23:00 to speed up Plex. I'd therefore be interested in your question too, as it's more useful. 1 Quote Link to comment
MJFox Posted October 13, 2020 Share Posted October 13, 2020 2 hours ago, Cessquill said: Hopefully somebody else can answer your actual question, but as a side thought you could replace... mdcmd spinup 0 mdcmd spinup 1 mdcmd spinup 2 ...with... disks=$(ls /dev/md* | sed "sX/dev/mdXX"); for disknum in $disks; do /usr/local/sbin/mdcmd spinup $disknum; done I currently run this on a CRON schedule every 10 minutes between 19:00 and 23:00 to speed up Plex. I'd therefore be interested in your question too, as it's more useful. thanks for your suggestion I just tried and tested my script and it works well in the background, I just changed "tail -F " to "tail -n 1 -F " so my script only checks the last line of the log-file give it a try Cheers MJFox Quote Link to comment
mgutt Posted October 13, 2020 Share Posted October 13, 2020 (edited) 5 hours ago, MJFOx said: is it ok to just start the script with the "At Startup of Array"- option? will it keep running in the background then? Yes, because "tail -F" monitors file changes, it will run forever. But I don't know if it could be killed somehow. Maybe it's better to set it to hourly and execute it atomic. I use this in my scripts: # make script race condition safe if [[ -d "/tmp/${0///}" ]] || ! mkdir "/tmp/${0///}"; then exit 1 fi trap 'rmdir "/tmp/${0///}"' EXIT Explanation: This generates a dir in the temp folder, which is deleted when the script is aborted. If the dir exists it aborts the execution (which prevents executing it twice). And I don't know if it would be a problem to spin up a drive, that is already spinning. Maybe we check the spin status first. I tried to find out which command returns such a status. The only one I found was this: mdcmd status 1 | grep rdevLastIO So the complete script would look like this: # make script race condition safe if [[ -d "/tmp/${0///}" ]] || ! mkdir "/tmp/${0///}"; then exit 1 fi trap 'rmdir "/tmp/${0///}"' EXIT # spin up drives on plex user login tail -F "/mnt/cache/appdata/plex/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log" | \ while read line ; do echo "$line" | tail -n 1 -F | grep "authenticated user" if [ $? = 0 ]; then disk0_status=$(mdcmd status | grep "rdevLastIO.0=" | cut -d '=' -f 2 | tr -d '\n') if [[ $disk0_status == "0" ]]; then echo "Spin up disk 0" mdcmd spinup 0 fi disk1_status=$(mdcmd status | grep "rdevLastIO.1=" | cut -d '=' -f 2 | tr -d '\n') if [[ $disk1_status == "0" ]]; then echo "Spin up disk 1" mdcmd spinup 1 fi disk2_status=$(mdcmd status | grep "rdevLastIO.2=" | cut -d '=' -f 2 | tr -d '\n') if [[ $disk2_status == "0" ]]; then echo "Spin up disk 2" mdcmd spinup 2 fi fi done I removed sleep as even if two users log in, it won't spinup twice as it checks the spinning status first. P.S. If disk0 is your parity drive, you don't need to spin it up Edited October 13, 2020 by mgutt Quote Link to comment
mgutt Posted October 13, 2020 Share Posted October 13, 2020 (edited) I thought about it again. What do you think if we monitor the Plex Container CPU load instead? By that it would work without enabling debugging in Plex, which is needed by the above script. I disabled debugging to avoid permanent writes on my SSD. EDIT: I created a version which monitors the load: Edited October 13, 2020 by mgutt Quote Link to comment
LSL1337 Posted October 19, 2020 Share Posted October 19, 2020 I have a VERY basic find+cp script, which works in the web command line, but doesn't, when I want to run it with custom scripts (I just tried it manually) Any ideas? #!/bin/bash find /mnt/user/mini/myfolder/ . -iname '*.mkv' -exec cp -n {} /mnt/user/mini/myfolder \; When I click Run Script, I get the find results, and "find: './sys/kernel/slab': Input/output error" And the cp can't start with this error in the find 'results'. What am I doing wrong? Btw i just try to copy files from the subfolders to the main folder. the subfolders will be deleted by the DL client, when seeding is done. Quote Link to comment
mgutt Posted October 19, 2020 Share Posted October 19, 2020 5 hours ago, LSL1337 said: When I click Run Script, I get the find results, and "find: './sys/kernel/slab': Input/output error" I wonder that this script works in the terminal as you passed two paths: "mnt/user/mini/myfolder/" and ".". Simply remove the dot. It means "search everywhere starting at the root folder" and when it tries to find something in "/sys/kernel/slab" it will be blocked, which produces the error. Other examples: https://stackoverflow.com/a/26234223/318765 Note: I would write the command in one line as "-exec" is part of the "find" command. Quote Link to comment
LSL1337 Posted October 19, 2020 Share Posted October 19, 2020 it worked with the ., but it was in 1 line in the web terminal. I removed the dot and the extra line, now it seems to be working. thanks! I didn't know the different line makes a difference even, it was just more readable for me Quote Link to comment
mgutt Posted October 19, 2020 Share Posted October 19, 2020 Different lines could mean different commands. But it depends on the type of shell/terminal. It should be possible for all shells if you use backslashes: https://stackoverflow.com/a/18599906/318765 Quote Link to comment
TheBeast Posted October 20, 2020 Share Posted October 20, 2020 plugin: installing: https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg plugin: downloading https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg plugin: downloading: https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg ... failed (Network failure) plugin: wget: https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg download failure (Network failure) Updating Support Links Finished Installing. If the DONE button did not appear, then you will need to click the red X in the top right corner how do i fix that ? Quote Link to comment
Squid Posted October 20, 2020 Author Share Posted October 20, 2020 Looks like a network config problem. Double check your DNS settings, Gateway, etc. Quote Link to comment
mgutt Posted October 22, 2020 Share Posted October 22, 2020 Updated today, now "RUN IN BACKGROUND" button does not work anymore. Popup window opens, but stays white and script is not executed. Quote Link to comment
racerx8413 Posted October 22, 2020 Share Posted October 22, 2020 I'm seeing the same issue ^ , 2020.10.21. White screen, no actual script execution when using "run in background". I have not tested a scheduled task.r 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.