[Plugin] CA User Scripts


Recommended Posts

9 hours ago, skunkworker said:

I'm running into a strange issue. When editing a script and then clicking "run in background" the newly edited script does not get run, but the older revision does. It took me touching the file in /tmp in order to get the script updated.

Gimme a day or so  I'll check it out

Link to comment
  • 4 weeks later...
4 hours ago, DZMM said:

basic question - if I have a custom cron schedule and a task is still running from the last execution (e.g. backup job), will the script get run again or only if it's not already running?

 

Thanks

It'll run a second instance.  To have it avoid that, your script needs to check if its already running

 

In pseudocode:

if tempFile exists then exit
create tempFile
the actual script here
remove tempFile

 

  • Upvote 1
Link to comment
26 minutes ago, Squid said:

It'll run a second instance.  To have it avoid that, your script needs to check if its already running

 

In pseudocode:


if tempFile exists then exit
create tempFile
the actual script here
remove tempFile

 

Very simple but effective - thank you. 

Link to comment
  • 2 weeks later...

I'm having an issue with user scripts where when I have a script set to run in the background and then abort it, it stays running. This is my script:

 

#!/bin/bash
#----------------------------------------------------------------------------
# This script mounts your remote share with the recommended options.         |
# Just define the remote you wish to mount as well as the local mountpoint.  |
# The script will create a folder at the mountpoint                          |
#----------------------------------------------------------------------------

# Local mountpoint
mntpoint="/mnt/disks/cloud" # It's recommended to mount your remote share in /mnt/disks/subfolder - 
                                # This is the only way to make it accesible to dockers

# Remote share
remoteshare="cache:" 	# If you want to share the root of your remote share you have to 
                                # define it as "remote:" eg. "acd:" or "gdrive:" 

home="/mnt/user/appdata/rclone"
tmpupload="$home/tmp"
#---------------------------------------------------------------------------------------------------------------------


mkdir -p $mntpoint
mkdir -p $tmpupload

rclone --allow-non-empty --allow-other mount $remoteshare $mntpoint --cache-db-path=$home --cache-tmp-upload-path=$tmpupload --cache-tmp-wait-time=30m -vv

And after "aborting" the script using the userscripts button this is what `ps auxw |grep rclone` says on the system:

 

root      3230  0.0  0.0   9812  2044 pts/0    S+   13:48   0:00 grep rclone
root     27063  0.0  0.0  11956  2908 ?        SN   12:48   0:00 /bin/bash /tmp/user.scripts/tmpScripts/rclone_mount_plugin/script
root     27066  0.0  0.0  11960  2908 ?        SN   12:48   0:00 /bin/bash /usr/sbin/rclone --allow-non-empty --allow-other mount cache: /mnt/disks/cloud --cache-db-path=/mnt/user/appdata/rclone --cache-tmp-upload-path=/mnt/user/appdata/rclone/tmp --cache-tmp-wait-time=30m -vv
root     27068  0.8  0.2 155556 66464 ?        SNl  12:48   0:31 rcloneorig --config /boot/config/plugins/rclone/.rclone.conf --allow-non-empty --allow-other mount cache: /mnt/disks/cloud --cache-db-path=/mnt/user/appdata/rclone --cache-tmp-upload-path=/mnt/user/appdata/rclone/tmp --cache-tmp-wait-time=30m -vv

This same behavior is apparent in my plexdrive backgrounded script also. After aborting it still stays running.

 

Am I doing something wrong here?

  • Like 1
Link to comment

Any long running commands do not get aborted. You want the user script to start the "real" script in the background by doing something like

echo "pathToScrip" | at NOW -m

Sent via Tapatalk because I'm either at work or enjoying the summer

  • Upvote 1
Link to comment

Ok, so I should fire off the mount with a subscript. And I suppose use a different script with a "killall rclone" or something like that?

 

Not as elegant as I was hoping for but as long as I can make it work it's fine.

 

I am curious to know why the abort button doesn't actually abort the script. It doesn't seem like it's very useful. If you set a script to "run in the background" it seems reasonable to assume the abort button will cancel that script. Right now it seems like it does nothing.

Link to comment
1 hour ago, endiz said:

I had to fresh install unraid.. after installing user scripts it seems like the icon is missing.. anyone else experiencing this issue?

 

image.png.1b60bba34341dc02d2a2eff6e25e3560.png

IDK  Looks like something went wrong for some reason on install.  I just did a fresh one and there's no problem with the icon

Link to comment

Hi guys, i need some help. I am trying to run custom cron of my scrub scripts, but recieve this:

 

unRaid crond[1825]: exit status 127 from user root * /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/Scrubc/script > /dev/null 2>&1

 

my script is: (\config\plugins\user.scripts\scripts\Scrubc\script)

#!/bin/bash
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive started" -i "normal" -m "Scrubbing message"
btrfs scrub start -rdB /mnt/cache > /boot/logs/scrub_cache.log
if [ $? -eq 0 ]
then
   /usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Scrub of cache drive finished" -i "normal" -m /boot/logs/scrub_cache.log
else
   /usr/local/emhttp/plugins/dynamix/scripts/notify -e "start_scrub_cache" -s "Scrub cache drive" -d "Error in scrub of cache drive !" -i "alert" -m /boot/logs/scrub_cache.log
fi

cron-custom.jpg.c5b1f916ee45fb40636e32e608850e00.jpg

 

Run/Run in Background works fine. Custom cron - dont.

Link to comment
10 hours ago, itimpi said:

you have 6 fields in the custom entry

 

Thank you so much for watching, man.
I fixed it to 5 fields, I'll see how it works, I'll write it helped or not ?
I'm almost sure that the reason for this

 

P.S. Thanks, @itimpi , Problem solved! 

Edited by vanes
Link to comment
  • 2 weeks later...
  • 2 weeks later...

hopefully a simple request for you linuxy experts.

I have the rclone custom script running to send CCTV footage of alerts to my gdrive.

The script runs minimum 1 hour in user scripts - in which time the thief may have found my unraid system and nicked it too....

The 'custom' allows for a cron type input.  What can I put in there for every 5 minutes ?

Link to comment
3 hours ago, vw-kombi said:

hopefully a simple request for you linuxy experts.

I have the rclone custom script running to send CCTV footage of alerts to my gdrive.

The script runs minimum 1 hour in user scripts - in which time the thief may have found my unraid system and nicked it too....

The 'custom' allows for a cron type input.  What can I put in there for every 5 minutes ?

 

*/5 * * * *

 

 

Link to comment

I installed a new usb drive, bc the old was failing from time to time.

 

I have CA Backup thingy. (but i cant find my scripts, only the preinstaleld scriptps got backed up ? )

 

Yesterday i set everything up, urrently i let a parity run. I thought all is fine, but  sadly all my custom scripts are lost... how to backup them?

Edited by nuhll
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.