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

Hi,

 

I'm new to Unraid.  I know how to make backups of VM's in Proxmox but I'm confused about how to do so in Unraid.

Am I understanding that this plug in let's you make a backup of your VM but the restore function is not actually implemented yet?  I ask because after making a few backups, when I click on the Restore button, nothing happens.  Am I doing something wrong or is this just how the plugin works for now? 

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

1 hour ago, spacecoog said:

this plug in let's you make a backup of your VM but the restore function is not actually implemented yet?  I ask because after making a few backups, when I click on the Restore button

Are you sure you're on the right thread? 

 

You can go directly to the correct support thread for any of your plugins by clicking its Support link on the Plugins page in your Unraid webUI. 

No, I posted on the wrong thread :(  

Hey just sitting here creating a script to remove tags automatically from qBittorrent (hate how cross-seed forces a tag) and realize how much for granted I take User Scripts.

 

Just wondering if there's a way to backup all these scripts I've accumulated over time!

They're on the flash drive, which you should backup regularly already.

Don't know if anybody mentioned or found this out before, but the custom cron format does not considering the alternative "day of week" format with three letters (MON-SUN).

Especially when referring to the crontab.guru I would assume, that it is the exact rebuild of the cron syntax.

Can I run a bash script using this tool? Filename Collections.sh

Not directly but you can create a script and paste the contents of that in.

On 2/25/2025 at 12:57 PM, Kilrah said:

They're on the flash drive, which you should backup regularly already.

 

OK, I had Grok create a quick script to back these up to a folder of your choice so you don't have to go digging through the USB backup.

 

This is considering I have a share called Backups.

Change destination directory to whatever you guys use.

 

 

#!/bin/bash

# Source directory
SOURCE="/boot/config/plugins/user.scripts/scripts"

# Base destination directory
BASE_DEST="/mnt/user/Backups/Server/Scripts"

# Get current date in YYYY-MM-DD format
DATE=$(date +%Y-%m-%d)

# Full destination path with date
DEST="$BASE_DEST/$DATE"

# Create destination directory if it doesn't exist
mkdir -p "$DEST"

# Copy all contents from source to destination
# -r: recursive copy
# -p: preserve file attributes
# -v: verbose output to see what's being copied
cp -rpv "$SOURCE"/* "$DEST/"

# Check if the copy was successful
if [ $? -eq 0 ]; then
    echo "Backup completed successfully to $DEST!"
else
    echo "Error: Backup failed!"
fi

 

2 hours ago, DevanteWeary said:

OK, I had Grok create a quick script to back these up to a folder of your choice so you don't have to go digging through the USB backup.

That script seems to only back up the user scripts, you always want a backup of the full flash drive anyway.

 

The Appdata Backup plugin most people use since you typically want your services' data backed up can do that for you. 

Hi, I'm having trouble with passing multiple arguments to a script. 

 

E.g. if I do it as in the example:

#argumentDescription=This is the description of the argument(s)
#argumentDefault=defaultArg1 defaultArg2

 

They togeter get parsed as a single argument.

E.g.:

echo "Argument1: $1"
echo "Argument2: $2"

Shows as:

Argument1: defaultArg1 defaultArg2
Argument2:

 

The description says that spaces in arguments are not supported, e.g. as if it should be handled as separate arguments.

But that does not seem to be the case.

 

I'm running Unraid 7.0.1, with userscripts plugin 2024.12.19.

Edited by BasUnraid
typo

Not sure if it’s always been like this for me, but I can’t seem to view the running log of a script set to run in background. 
 

if I click the icon to view the log, a page opens up with an address of unraid.home/logging.htm and all that’s in that page is a button with the text UNDEFINED

 

if I run a script in the foreground I can see it’s log running. Any ideas why this is happening?

Is the CA User Scripts plugin open for development contributions?   I'd be interested in having a syntax check button on the script editing page to check your work prior to executing the script.  

  • Author
On 3/10/2025 at 2:55 PM, BasUnraid said:

But that does not seem to be the case.

 

Looking at the code, it appears that this is a bug

 

  • Author
7 hours ago, timrettop said:

Is the CA User Scripts plugin open for development contributions?   I'd be interested in having a syntax check button on the script editing page to check your work prior to executing the script.  

Always.  You can fork and make PRs on GitHub (PM as I tend to get about 50 notifications a day from GitHub so might not notice

  • 2 weeks later...

 Hi, I've been running a user script for over 10 years which records a radio show every day. After upgrading to unRAID 7.x , this broke and I cannot figure out why!

 

#!/bin/bash

streamripper "http://media-ice.musicradio.com/RadioXUKMP3.m3u" -a -A -d /mnt/cache/streamripper/test -l 14400

 

If I manually press run script in the userscripts settings page, the script runs correctly. If I paste the line in to a shell, it runs correctly. 

 

But, when triggered by cron, it errors out. 

 

Connecting...

error -3 [SR_ERROR_INVALID_URL]
bye..
shutting down
Script Finished Mar 25, 2025  17:13.02

Full logs for this script are available at /tmp/user.scripts/tmpScripts/streamripperTCMS_M_F/log.txt

 

As mentioned, all was good before 7.0

 

Hope someone can help! 

 

Cheers,

 

Neil

  • 2 weeks later...

Since upgrading to Unraid 7.1.0 (atm on beta 2) plugin stopped working at all. Tried reinstalling, removing old directories, starting from scratch, but still unable to make it work properly.

 

The gui works fine, I am able to run script / run in the background, but after clicking that it seems to invoke script behind the script name (as it looks like that in syslog), but unfortunately it is not doing anything, not starting it at all.

 

It's hard to debug it, as it is not sending anything to logs besides e.g. :

 

emhttpd: cmd: /usr/local/emhttp/plugins/user.scripts/startScript.sh /tmp/user.scripts/tmpScripts/jdupes/script

 

 

Any idea what else can I do?

//Edit:

 

In case someone is going to have same issue, the problem was with zsh as my main shell. The scripts are calling source ${HOME}/.bashrc but my default shell is zsh, so it was unable to run it. After changing .bashrc to zshrc it works fine

Edited by silverkin

On 2/14/2025 at 10:01 AM, sasbro97 said:

Hey guys I got a short question. I created a small bash script with user scripts that should set alias values on array startup. The values are set but trying to load the changes does not work with 

source /root/.bashrc

because it is executed in the script. As I can not do anything about the execution of the script, I don't know how to fix it.

 

I cannot call the script with the dot notation like this:

. /root/.bashrc

 

Any ideas?

Still nobody with an idea?

  • 1 month later...

Suppose I want to create an "on demand" script that I can reference in other scheduled scripts.  For reasons of organization, I'd like this script to be defined in User Scripts.

 

It appears that I cannot call the script directly from the specified location (`/boot/config/plugins/user.scripts/scripts/TodayYesterdayShuffle`) because that script file does not have the execute permission set.  Furthermore, it appears that the temporary location where scheduled scripts run from (`/tmp/user.scripts/tmpScripts`) does not contain this on-demand script (presumably because I have never executed it from the User Scripts GUI).

 

Is there a way to do this?  Perhaps some CLI manner of clicking the "Run Script" button in the GUI?

 

I understand that I could save the script file in a user share and set the execute permissions as needed, but I'd rather not so as to minimize the amount of "figuring out" I need to do when I haven't looked at these scripts in 5 years and have to troubleshoot something.

 

Thank you for any thoughts you can offer!

4 hours ago, tkohhh said:

Suppose I want to create an "on demand" script that I can reference in other scheduled scripts.  For reasons of organization, I'd like this script to be defined in User Scripts.

 

It appears that I cannot call the script directly from the specified location (`/boot/config/plugins/user.scripts/scripts/TodayYesterdayShuffle`) because that script file does not have the execute permission set.  Furthermore, it appears that the temporary location where scheduled scripts run from (`/tmp/user.scripts/tmpScripts`) does not contain this on-demand script (presumably because I have never executed it from the User Scripts GUI).

 

Is there a way to do this?  Perhaps some CLI manner of clicking the "Run Script" button in the GUI?

 

I understand that I could save the script file in a user share and set the execute permissions as needed, but I'd rather not so as to minimize the amount of "figuring out" I need to do when I haven't looked at these scripts in 5 years and have to troubleshoot something.

 

Thank you for any thoughts you can offer!

TRy this:

bash /boot/config/plugins/user.scripts/scripts/TodayYesterdayShuffle

 

18 hours ago, ICDeadPpl said:

TRy this:

bash /boot/config/plugins/user.scripts/scripts/TodayYesterdayShuffle

 

Hey, that worked! What's the concept here?  `bash` is executing the text inside the file rather than trying to execute the file directly, thus bypassing the execute permission?

  • Author
49 minutes ago, tkohhh said:

Hey, that worked! What's the concept here?  `bash` is executing the text inside the file rather than trying to execute the file directly, thus bypassing the execute permission?

Exactly.  Executables on the flash drive are explicitly denied.

  • 2 weeks later...
On 3/14/2025 at 3:02 PM, rorton said:

Not sure if it’s always been like this for me, but I can’t seem to view the running log of a script set to run in background. 
 

if I click the icon to view the log, a page opens up with an address of unraid.home/logging.htm and all that’s in that page is a button with the text UNDEFINED

 

if I run a script in the foreground I can see it’s log running. Any ideas why this is happening?

-----> exact the same here. 

For background scripts, I don't think I've ever been able to see the logs unless I bring up a session and tail the log file (which I do a lot these days when testing out a script). You can use something like Putty or the built in terminal in Unraid, navigate to the directory where your log file is and then "tail -f this-is-my-log-file.log" to see the output as it runs.

 

 

  • Author
On 5/20/2025 at 9:52 AM, jmbailey2000 said:

For background scripts, I don't think I've ever been able to see the logs unless I bring up a session and tail the log file (which I do a lot these days when testing out a script). You can use something like Putty or the built in terminal in Unraid, navigate to the directory where your log file is and then "tail -f this-is-my-log-file.log" to see the output as it runs.

 

 

The log file is composed of whatever is outputted to stdout in the script. Can't remember OTOH if it also catches stderr

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.