Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Plugin] CA User Scripts

Featured Replies

7 hours ago, Squid said:

Everything echo'd from your script is what constitutes the log

 

I see. Is it possible to get the same info that I would get by running the command in terminal? I am running a jdupe command, and would like to be able to see how far in the process it has come from looking at the logs

  • Replies 2.1k
  • Views 567.2k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • I could make up something long, convoluted, and technical as a reason why it doesn't do that but it would all be bs.  The simple answer is that when I did this, I never thought of that, and why it sti

  • Hi All - We have a fix and are publishing a Connect plugin update to fix it today. Thanks for letting us know.

  • @Squid I tried many commands and by that I found out that pkill does not kill (all) child processes: root@Thoth:/tmp# pgrep -f isleep2m | xargs --no-run-if-empty ps fp PID TTY STAT T

Posted Images

Is "At stopping of array" in User Scripts occur before, during, or after the array is stopping?  Same question with ""at start of array".

I would like to setup my unraid to switch on/off my JBOD (via APC control) that are all the UNRAID disks before/after UNRAID starts, but not sure it will work in the correct order to function properly.

  • Author

Stopping happens before (while the services at being stopped).  Starting happens after the disks are mounted

On 2/10/2022 at 2:05 PM, Squid said:

Instead of 2-31 and 0-4,6 use 2,3,4,5 .... and 0,1,2,3,4,6

 

Hi again,

so, it took me a while, but unfortunately it does not work..

is that cron setting general to complicated, to long, or can there be something wrong on my system?

 

can I provide any additional information for analysis?

 

thanks in advance!

  • Author

There's no error checking at all on the custom entry, so whatever you use should get automatically added.

ok what now?

does that mean, i cannot use this?

neither

0 1 2-31 * 0-4,6

nor

0 1 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 * 0,1,2,3,4,6

is working

but i really would like to exclude fridays (backups of some vms from a different host roll in) and the first day of the month (monthly parity check) with this setting.

 

any other suggestions?

hmm.. can i check this within the script?

so that it runs daily, but if it sees its friday, or first day of the month, then exit?

 

I'm not an expert, I've just copied @mgutt's backup-script (thank you!) and changed it a little

 

thanks in advance!

  • 2 weeks later...

Is it possible to source in other files (with functions and/or presetted variables) into the main "script".

I'm tinkering with a script and would like a lot of functions to be in a different file to reduce the size of the actual script and keep the main-script clean and tidy. I noticed scripts that are running have their script copied to /tmp/user.scripts/tmpScripts. Will that affect sourcing in files difficult?

Just installed the plugin! Thanks a lot Squid. One thing I wanted to call out was that the "What is Cron" link in the top left is linked to a dead webpage - it directs you to https://corntab.com instead of https://crontab.com. Additionally, crontab.com seems to be deprecated as well and the closest page I was able to find is https://crontab.guru.

 

Hope this helps :)

Hello

 

How schedule it is working?

it doesn't work for me
 

Capture d’écran 2022-03-04 190140.png

its minute 48 and hour 18

 

Ok miss the stars

thanks

 

Edited by Falcom

  • Author

And you forgot about day of month, month, and day of week.  Or in your case, * * *

26 minutes ago, Falcom said:

Hello

 

How schedule it is working?

it doesn't work for me
 

Capture d’écran 2022-03-04 190140.png

Looks like you’re missing the asterisks.

48 18 * * *

 

Users scripts not persistent on reboot. How to I get the script to run afte reboot? It works fine when I first apply the script but it will not run unless manually triggered after reboot. I have set to custom */1 * * * *. I also tried * * * * *

 

edit: It looks like user-scripts doesn't execute until the array is started. Anyway to do this regardless of array state?

Edited by xxnumbxx

  • Author
1 hour ago, xxnumbxx said:

edit: It looks like user-scripts doesn't execute until the array is started. Anyway to do this regardless of array state?

No.  Not because it's not an easy thing to do, but mainly because I don't want to deal with the inevitable support requests caused by that.

 

Edit the "go" file (/config/go on the flash drive) to accomplish this

On 3/6/2022 at 4:55 PM, Squid said:

No.  Not because it's not an easy thing to do, but mainly because I don't want to deal with the inevitable support requests caused by that.

 

Edit the "go" file (/config/go on the flash drive) to accomplish this

Fair enough. Thank you.

I'm not sure this is the right place to post my question because I can't create a new topic under the application support/plugins section.
I've created 2 user scripts, say script A and B, under CA User Scripts plugin. Script B is supposed to be called by several scripts with passing arguments. In this case, Script A will call script B and also pass 4 arguments to B. I know how to do it under native Debian bash script, but I don't know how to acheive this under CA User Scripts plugin.
Would appreciate any guidance.

 

update: I found the solution, to call other script defined in CA User Script, e.g. to call script named "subscriptB":

sh /boot/config/plugins/user.scripts/scripts/subscriptB/script arg1 arg2 arg3 .....

Edited by bthoven
to add solution

  • Author
19 hours ago, bthoven said:

update: I found the solution, to call other script defined in CA User Script, e.g. to call script named "subscriptB":

sh /boot/config/plugins/user.scripts/scripts/subscriptB/script arg1 arg2 arg3 .....

Yeah, nothing on the flash drive is directly executable, so the sh (or /bin/bash) is required

I'm using the CA User Scripts plugin with some scripts that are scheduled to run in the background. Works great for my backup script.

 

There's a "Show log" button for the script, but it only shows the last 41 lines or so from the log. I know I can go into the full log at /tmp/user.scripts/tmpScripts/scriptname/log.txt, but is there a way to lengthen the number of lines that the "Show log" button shows?

  • Author

Unfortunately, no.  User scripts leverages the built-in dynamix log viewer, so it's limited by it's display constraints.

Only just started to really use this plugin and dropped adding scripts to crontab.  Kicking myself for not migrating to this earlier.

 

Quick question.  I have a need to add an entry to the hosts file of about 3 dockers after they start up (a server i am trying to reach has had it's domain name snatched so a hosts file entry is the only way to get to it).

 

Is there a way I can trigger CAUS to to run a script upon docker start?  Or maybe 5/10 mins after array start?

While I am at it, any tips on writing a script that can be run from the console to had hosts entries in docker containers?  Or is there a simpler way to do it?

1 hour ago, dalben said:

 

Is there a way I can trigger CAUS to to run a script upon docker start? 

Reverse your logic and it's pretty easy.

 

echo "_waiting 5 minutes"
                        sleep 300

echo "_starting Container X"
                       /usr/bin/docker start (container X)

echo "_starting Container Y"
                       /usr/bin/docker start (container Y)

echo "_starting Container Z"
                       /usr/bin/docker start (container Z)

echo "_modifying hosts"

                     ?command to add hosts entry?

 

Disable auto start for the containers, set the script to start at array start, it waits 5 minutes, starts the container(s), then does your hosts thing.

 

1 hour ago, dalben said:

While I am at it, any tips on writing a script that can be run from the console to had hosts entries in docker containers?

 

Sorry, no help there. Why does it have to be limited to those containers, and why only after start? Couldn't you just do the magic in your router, or in Unraid itself?

7 hours ago, JonathanM said:

Reverse your logic and it's pretty easy.

Thanks, that makes sense.

 

7 hours ago, JonathanM said:

 Couldn't you just do the magic in your router, or in Unraid itself?

Didn't think of that, but yes, I'll try the Unraid way first.  Makes life a lot easier

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

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.