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

Relatively new Unraid install - 6.11.1. Installed the User Scripts plugin. I am unable to "Apply" any changes whether it's changing the schedule from the dropdown list or setting a cron schedule. Pressing the Apply button seems to do nothing, pressing Done losses all changes. I've tried Firefox, Chrome, and Edge. I uninstalled the plugin but then reinstalling it just retained any previous scripts and settings and the Apply button still doesn't function. Thoughts?

  • Replies 2.1k
  • Views 567.1k
  • 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

After a server restart all my schedules aren't set, but there are still in the plugins config file?!

 

image.thumb.png.39a9dfabb41665bb609972db6a0b6c92.png

 

image.thumb.png.96a8c56ff8e3bda52c66d860f04d1562.png

Edited by geromme

Disregard, I am a blooming idiot who can't read properly.

 

Edited by Viper359

Since I updated User-Script to the latest version and updated Unraid to 6.11.1, my User-Script cannot display logs, what is the reason?

image.png

7 hours ago, kennand said:

Since I updated User-Script to the latest version and updated Unraid to 6.11.1, my User-Script cannot display logs, what is the reason?

 

and they already ran once ? as if you just updated ... they need to run atleast once to have a log ;)

 

just in case you expected "old" logs ;)

  • Author

And they're not persistent - all logs are lost on a reboot

4 minutes ago, usr.local said:

Wouldn't it be better to save logs to /boot/logs so they are persistent?

 

Logs can take up a lot of space and hammer a lot of writes -- which isn't great for a USB stick.

 

My scripts make a copy of the latest log files, as I need them, to my storage.

17 hours ago, alturismo said:

and they already ran once ? as if you just updated ... they need to run atleast once to have a log ;)

 

just in case you expected "old" logs ;)

yes,they already run many times

2 hours ago, usr.local said:

I log all of them to /boot/logs and have never had to replace my USB drive.

Why not just use the builtin syslog server?

4 hours ago, usr.local said:

I can't imagine that you would use more memory available on a usb stick to make that much difference.  If you you do, then I would say you should purchase a decent USB stick for less than $20.00.

 

Not so much about how much memory storage a USB drive has than trying to limit how much writing activity the flash drive sees.  Thumb drives aren't designed to be a general storage drive but rather for storage to archive and transport data from one system to another.  One of the main reasons of flash drive failure is from heat generated from continuous writes.  It has become more an issue with drives capacities and speeds increasing.  Most flash drives have little to no heat absorbing mass to dissipate the heat generated by multiple writes.

 

While text logs generally don't have many writes, it still may be best to be in the mindset to limit writes to your boot flash to only those that are needed to be there.

 

There has also been a large number of people finding themselves with counterfeit flash drives they though were genuine products from major suppliers (SanDisk, Samsung).  Many of these were purchased from popular sources such as Amazon.  So you can not know for sure your new flash drive is one of the decent ones.

10 hours ago, kennand said:

yes,they already run many times

then i would start run it manually and see what comes in the box, if there are "logs" and not written to logs ... may take a look at syslog parallel to see if there are any errors like "not writeable" ...

On 11/1/2022 at 3:05 AM, alturismo said:

then i would start run it manually and see what comes in the box, if there are "logs" and not written to logs ... may take a look at syslog parallel to see if there are any errors like "not writeable" ...

I found that only when I click "run in background" can logs appear. If I click "RUN SCRIPT" or run script automatically on a regular basis, no logs will be generated

On 10/31/2022 at 5:22 AM, usr.local said:

I can't imagine that you would use more memory available on a usb stick to make that much difference.  If you you do, then I would say you should purchase a decent USB stick for less than $20.00.

 

 

One configuration mistake, or some issue, and you could write gigs to a log file. It depends on the log file. You generally never want to write logs to a boot folder/partition/drive. 

I have a rsync job running every 5 mins from 6AM to 10PM but the cron job doesn't honor the schedule. Is my schedule format correct?

 

0/5 6-22 * * *

  • Author
9 hours ago, aarontry said:

I have a rsync job running every 5 mins from 6AM to 10PM but the cron job doesn't honor the schedule. Is my schedule format correct?

 

0/5 6-22 * * *

I would try expanding the 6-22 to instead be 6,7,8...

Hi, I have a very simple python script but if I run it via the user scripts the execution is not in order.

 

subprocess.run running before everything at the start of the script, however it is called later in the script.

 

Do you have idea what is causing this? If I run the script manually in ssh shell it is executing the commands in order.

 

edit: I am not sure right now. Maybe just the output is not in order in the log?

 

The script:

#!/usr/bin/python3

import shutil
import subprocess

print("Starting")

letsencryptCert = "/mnt/user/appdata/swag/etc/letsencrypt/live/my.domain/priv-fullchain-bundle.pem"
guiCert = "/boot/config/ssl/certs/TOWER_unraid_bundle.pem"

print("Copy certificate...")
shutil.copyfile(letsencryptCert, guiCert)

print("Reload WebGUI...")
subprocess.run(["/etc/rc.d/rc.nginx", "reload"])

print("Finished")

 

Edited by MasterMark

Is there a way to run a script not only after the array is started but only when the docker daemon is available?

I'm having an issue with my scripts not showing the logs after clicking on Run Script. The logs will show after clicking on Run in Background. 

I believe my NTP server settings weren't correct. I fixed that, but I still can't get two of my scripts to work at all. 

 

 

Could anyone tell me what is going on?

 

Here are the two scripts I need help with:

-first "arraycache errors":

Spoiler
#!/bin/bash
if mountpoint -q /mnt/arraycache; then
btrfs dev stats -c /mnt/arraycache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on arraycache pool"; fi
fi

 

-second "plexcache errors":

Spoiler

#!/bin/bash
if mountpoint -q /mnt/plexcache; then
btrfs dev stats -c /mnt/plexcache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on plexcache pool"; fi
fi

 

Here's the output of "cat /etc/cron.d/root":

Spoiler

root@Threadripper19:~# cat /etc/cron.d/root
# Generated btrfs balance arraycache schedule:
0 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/arraycache -dusage=50 &> /dev/null

# Generated btrfs balance nvmecache schedule:
30 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/nvmecache -dusage=50 &> /dev/null

# Generated btrfs balance plexcache schedule:
5 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/plexcache -dusage=50 &> /dev/null

# Generated docker monitoring schedule:
10 0 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check &> /dev/null

# Generated languages version check schedule:
10 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/languagecheck &> /dev/null

# Generated system monitoring schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null

# Generated mover schedule:
0 9 * * 0 /usr/local/sbin/mover &> /dev/null

# Generated parity check schedule:
0 22 * 1,4,7,10 2 [[ $(date +%e -d +7days) -le 7 ]] && /usr/local/sbin/mdcmd check NOCORRECT &> /dev/null || :
# Generated plugins version check schedule:
10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null

# Generated btrfs scrub arraycache schedule:
0 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/arraycache -r &> /dev/null

# Generated btrfs scrub nvmecache schedule:
30 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/nvmecache -r &> /dev/null

# Generated btrfs scrub plexcache schedule:
5 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/plexcache -r &> /dev/null

# Generated ssd trim schedule:
0 1 * * 0 /sbin/fstrim -a -v | logger &> /dev/null

# Generated array status check schedule:
20 0 * * 1 /usr/local/emhttp/plugins/dynamix/scripts/statuscheck &> /dev/null

# Generated Unraid OS update check schedule:
11 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null

# Generated cron settings for docker autoupdates
0 9 * * 0 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1
# Generated cron settings for plugin autoupdates
0 10 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1

I'm also attaching my unRAID diagnostics for your review. 

 

Any help is appreciated. 

Thanks

threadripper19-diagnostics-20221107-2014.zip

Edited by FQs19
spelling correction

6 minutes ago, FQs19 said:

I'm having an issue with my scripts not showing the logs after clicking on Run Script. The logs will show after clicking on Run in Background. 

I believe my NTP server settings weren't correct. I fixed that, but I still can't get two of my scripts to work at all. 

 

 

Could anyone tell me what is going on?

 

Here are the two scripts I need help with:

-first "arraycache errors":

  Reveal hidden contents
#!/bin/bash
if mountpoint -q /mnt/arraycache; then
btrfs dev stats -c /mnt/arraycache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on arraycache pool"; fi
fi

 

-second "plexcache errors":

  Reveal hidden contents

#!/bin/bash
if mountpoint -q /mnt/plexcache; then
btrfs dev stats -c /mnt/plexcache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on plexcache pool"; fi
fi

 

Here's the output of "cat /etc/cron.d/root":

  Reveal hidden contents

root@Threadripper19:~# cat /etc/cron.d/root
# Generated btrfs balance arraycache schedule:
0 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/arraycache -dusage=50 &> /dev/null

# Generated btrfs balance nvmecache schedule:
30 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/nvmecache -dusage=50 &> /dev/null

# Generated btrfs balance plexcache schedule:
5 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/plexcache -dusage=50 &> /dev/null

# Generated docker monitoring schedule:
10 0 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check &> /dev/null

# Generated languages version check schedule:
10 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/languagecheck &> /dev/null

# Generated system monitoring schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null

# Generated mover schedule:
0 9 * * 0 /usr/local/sbin/mover &> /dev/null

# Generated parity check schedule:
0 22 * 1,4,7,10 2 [[ $(date +%e -d +7days) -le 7 ]] && /usr/local/sbin/mdcmd check NOCORRECT &> /dev/null || :
# Generated plugins version check schedule:
10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null

# Generated btrfs scrub arraycache schedule:
0 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/arraycache -r &> /dev/null

# Generated btrfs scrub nvmecache schedule:
30 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/nvmecache -r &> /dev/null

# Generated btrfs scrub plexcache schedule:
5 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/plexcache -r &> /dev/null

# Generated ssd trim schedule:
0 1 * * 0 /sbin/fstrim -a -v | logger &> /dev/null

# Generated array status check schedule:
20 0 * * 1 /usr/local/emhttp/plugins/dynamix/scripts/statuscheck &> /dev/null

# Generated Unraid OS update check schedule:
11 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null

# Generated cron settings for docker autoupdates
0 9 * * 0 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1
# Generated cron settings for plugin autoupdates
0 10 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1

I'm also attaching my unRAID diagnostics for your review. 

 

Any help is appreciated. 

Thanks

threadripper19-diagnostics-20221107-2014.zip 140.82 kB · 0 downloads

 

It would help if I actually started my array. 

Attached is the diagnostics after starting my array and running the first script with Run then Run in Background. 

Here's the output of "cat /etc/cron.d/root":

Spoiler
root@Threadripper19:~# cat /etc/cron.d/root
# Generated btrfs balance arraycache schedule:
0 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/arraycache -dusage=50 &> /dev/null

# Generated btrfs balance nvmecache schedule:
30 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/nvmecache -dusage=50 &> /dev/null

# Generated btrfs balance plexcache schedule:
5 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/plexcache -dusage=50 &> /dev/null

# Generated docker monitoring schedule:
10 0 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check &> /dev/null

# Generated languages version check schedule:
10 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/languagecheck &> /dev/null

# Generated system monitoring schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null

# Generated mover schedule:
0 9 * * 0 /usr/local/sbin/mover &> /dev/null

# Generated parity check schedule:
0 22 * 1,4,7,10 2 [[ $(date +%e -d +7days) -le 7 ]] && /usr/local/sbin/mdcmd check NOCORRECT &> /dev/null || :
# Generated plugins version check schedule:
10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null

# Generated btrfs scrub arraycache schedule:
0 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/arraycache -r &> /dev/null

# Generated btrfs scrub nvmecache schedule:
30 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/nvmecache -r &> /dev/null

# Generated btrfs scrub plexcache schedule:
5 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/plexcache -r &> /dev/null

# Generated ssd trim schedule:
0 1 * * 0 /sbin/fstrim -a -v | logger &> /dev/null

# Generated array status check schedule:
20 0 * * 1 /usr/local/emhttp/plugins/dynamix/scripts/statuscheck &> /dev/null

# Generated Unraid OS update check schedule:
11 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null

# Generated cron settings for docker autoupdates
0 9 * * 0 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1
# Generated cron settings for plugin autoupdates
0 10 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1

# CRON for CA background scanning of applications
26 * * * * php /usr/local/emhttp/plugins/community.applications/scripts/notices.php > /dev/null 2>&1

# Generated local master browser check:
*/1 * * * * /usr/local/emhttp/plugins/dynamix.local.master/scripts/localmaster &> /dev/null

# Generated system data collection schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix.system.stats/scripts/sa1 1 1 &> /dev/null

# Generated cron schedule for user.scripts
0 0,8,16 * * * /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/btrfs_error_monitoring/script > /dev/null 2>&1
0 0,,8,16 * * * /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/btrfs_error_monitoring_plexcache/script > /dev/null 2>&1

 

 

threadripper19-diagnostics-20221107-2020.zip

Here is my super simple script... 
 

#!/bin/bash
cd /mnt/user/data/bullmoose20/Documents/Plex-Meta-Manager-Images
sudo tree --charset=ascii people > people_listing2.txt

##############
# chown      #
##############
chown nobody people_listing2.txt

##############
# chgrp      #
##############
chgrp users people_listing2.txt

##############
# chmod      #
##############
chmod 666 people_listing2.txt


When I run this manually in Unraid User Scripts, I get the following output:

 

people
|-- bw
|   |-- Aaron Beelner.jpg
|   |-- Aaron Eckhart.jpg
|   |-- Aaron Lazar.jpg
|   |-- Aaron Nee.jpg
|   |-- Aaron O'Connell.jpg
|   |-- Aaron Paul.jpg
|   |-- Aaron Ryder.jpg
|   |-- Aaron Schneider.jpg
|   |-- Aaron Schwartz.jpg
|   |-- Aaron Sorkin.jpg
|   |-- Aaron Stanford.jpg
|   |-- Aaron Taylor-Johnson.jpg
|   |-- Aaron W Reed.jpg
|   |-- Aarón Díaz.jpg
|   |-- Abbey Hoes.jpg
|   |-- Abby Elliott.jpg


However, when it runs every 5 minutes, I get the following output:
 

people
|-- bw
|   |-- Aaron\ Beelner.jpg
|   |-- Aaron\ Eckhart.jpg
|   |-- Aaron\ Lazar.jpg
|   |-- Aaron\ Nee.jpg
|   |-- Aaron\ O'Connell.jpg
|   |-- Aaron\ Paul.jpg
|   |-- Aaron\ Ryder.jpg
|   |-- Aaron\ Schneider.jpg
|   |-- Aaron\ Schwartz.jpg
|   |-- Aaron\ Sorkin.jpg
|   |-- Aaron\ Stanford.jpg
|   |-- Aaron\ Taylor-Johnson.jpg
|   |-- Aaron\ W\ Reed.jpg
|   |-- Aar\303\263n\ D\303\255az.jpg
|   |-- Abbey\ Hoes.jpg
|   |-- Abby\ Elliott.jpg


Notice the backslashes and notice the Aarón Díaz.jpg is missing the characters. 

Any way I can fix this so that when it runs with the schedule, it keeps the characters and eliminates the backslashes?

Is there a documentation about the "custom cron schedule" syntax ?

I want to run a script every day at 0:00 but don't know how to write it

 

31 minutes ago, matuopm said:

Is there a documentation about the "custom cron schedule" syntax ?

I want to run a script every day at 0:00 but don't know how to write it

 

 

The cron Wikipedia article explains the syntax pretty well. You can use a generator, e.g. Crontab.guru, to get the expression you need. "Every day at 0:00" would be:

0 0 * * *

hello, user-scripts noob here. having some issues getting this to work right, i am trying to get it to run steam-lancache-prefill on a schedule, but it doesn't seem to be passing the `prefill` arg. Am i doing something wrong?


 

#!/bin/bash
#arrayStarted=true
#argumentDescription=SteamPrefill command
#argumentDefault=prefill

cd "/mnt/lancache/steam-prefill"
./SteamPrefill

 

it just outputs the same as if i ran `./SteamPrefill` via terminal.

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.