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

3 minutes ago, scubieman said:

dont see it 

Scroll down some more.

  • 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

You see by the scroll bar I am to the bottom.

 

 

image.thumb.png.5fd606e1e8333e308d824f90b7fc5857.png

  • Author

You need to install the dynamix Schedules plugin to be able to adjust the Daily/Weekly/Monthly times

2 minutes ago, Squid said:

You need to install the dynamix Schedules plugin to be able to adjust the Daily/Weekly/Monthly times

That works better. Thank you!

  • 2 weeks later...

Edit: Ignore - found a better way of tackling my problem

 

Can I get some help from someone more knowledgeable than me please.  What I want to do is check if a directory on my array is larger than 100GB e.g. check if /mnt/user0/downloads/nzbget is larger than 100GB.

 

The reason I want to do this is if I can work out how to do the check, if positive I'll pause my downloads as I'm finding that if mover moves too many files to the array before they are added to the right directory I start suffering IO meltdown.

 

Thanks in advance.

Edited by DZMM

7 minutes ago, DZMM said:

Can I get some help from someone more knowledgeable than me please.  What I want to do is check if a directory on my array is larger than 100GB e.g. check if /mnt/user0/downloads/nzbget is larger than 100GB.

 

The reason I want to do this is if I can work out how to do the check, if positive I'll pause my downloads as I'm finding that if mover moves too many files to the array before they are added to the right directory I start suffering IO meltdown.

 

Thanks in advance.

du -sh /mnt/user0/downloads/nzbget

 

40 minutes ago, trurl said:

du -sh /mnt/user0/downloads/nzbget

 

Thanks I know how to get the size, but how do I do the if bigger than 100GB then.... bit?

I'm trying to run the VM Config Backup script and receiving the errors in the code box below. The path that is to be used and was added to the config file is:

 

/mnt/user/030 - IT Support/Backup Data/Unraid/VM Settings

 

I pretty sure this is an issue with the spaces and/or the dash in the path name but I have tried a bunch of different syntax including single quotes, backslashes to remove the spaces, etc. Just cant seem to get it right. Can anybody assist with how this path should be defined in the config?

 

Thanks!

Script location: /tmp/user.scripts/tmpScripts/vm settings backup/script
Note that closing this window will abort the execution of this script
/tmp/user.scripts/tmpScripts/vm settings backup/script: line 10: [: too many arguments
As /mnt/user/030 - IT Support/Backup Data/Unraid/VM Settings//vmsettings/_27_Jan_2019 exists continuing.
Saving vm xml files
rsync: link_stat "/mnt/user/030" failed: No such file or directory (2)
rsync: link_stat "/-" failed: No such file or directory (2)
rsync: link_stat "/IT" failed: No such file or directory (2)
rsync: change_dir "/Support" failed: No such file or directory (2)
rsync: change_dir "/Data/Unraid" failed: No such file or directory (2)
rsync: mkdir "/Settings//vmsettings/_27_Jan_2019/xml" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(664) [Receiver=3.1.3]
Saving ovmf nvram
rsync: link_stat "/mnt/user/030" failed: No such file or directory (2)
rsync: link_stat "/-" failed: No such file or directory (2)
rsync: link_stat "/IT" failed: No such file or directory (2)
rsync: change_dir "/Support" failed: No such file or directory (2)
rsync: change_dir "/Data/Unraid" failed: No such file or directory (2)
rsync: mkdir "/Settings//vmsettings/_27_Jan_2019/nvram" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(664) [Receiver=3.1.3]
chmod: cannot access '/mnt/user/030': No such file or directory
chmod: cannot access '-': No such file or directory
chmod: cannot access 'IT': No such file or directory
chmod: cannot access 'Support/Backup': No such file or directory
chmod: cannot access 'Data/Unraid/VM': No such file or directory
chmod: cannot access 'Settings//vmsettings/_27_Jan_2019': No such file or directory

 

48 minutes ago, CraigGivant said:

I'm trying to run the VM Config Backup script and receiving the errors in the code box below. The path that is to be used and was added to the config file is:

 

/mnt/user/030 - IT Support/Backup Data/Unraid/VM Settings

 

I pretty sure this is an issue with the spaces and/or the dash in the path name but I have tried a bunch of different syntax including single quotes, backslashes to remove the spaces, etc. Just cant seem to get it right. Can anybody assist with how this path should be defined in the config?

Personally I wouldn't put spaces in a user share name just to avoid these sorts of problems.

18 minutes ago, trurl said:

Personally I wouldn't put spaces in a user share name just to avoid these sorts of problems.

I can appreciate that but the horse has already left the barn. I also believe this not only affects the share name but also the folders within the share. I migrated all data over from a Qnap and literally have thousands of folders. I certainly don't want to rename them all as even if there was a script to do this easily we have too many programs that would need to be re-pathed to find their data. I have had no issues with anything (including VM's and Dockers) using paths with spaces. I have only encounters it in this plugin as per above as well as with spaceinvaders icon pack downloader.

 

Hoping for a simple way to define this path properly to work with the scripts and if not I'll just have to create a different share.

I got this to work but not as eloquently as the original script. Once I figured out the path syntax, nothing I did would pass the backuplocation variable properly to the rest of the script. I removed the variable and directly entered the path in all instance of $dir. Here is what worked:

 

#!/bin/bash
#backs up
datestamp="_"`date '+%d_%b_%Y'`
mkdir -vp '/mnt/user/'030\ -\ IT\ Support'/'Backup\ Data'/Unraid/'VM\ Settings'/'$datestamp'/nvram'
mkdir -vp '/mnt/user/'030\ -\ IT\ Support'/'Backup\ Data'/Unraid/'VM\ Settings'/'$datestamp'/xml'
echo "Saving vm xml files"
rsync -a --no-o /etc/libvirt/qemu/*xml '/mnt/user/'030\ -\ IT\ Support'/'Backup\ Data'/Unraid/'VM\ Settings'/'$datestamp'/xml'
echo "Saving ovmf nvram"
rsync -a --no-o /etc/libvirt/qemu/nvram/* '/mnt/user/'030\ -\ IT\ Support'/'Backup\ Data'/Unraid/'VM\ Settings'/'$datestamp'/nvram'
chmod -R 777 '/mnt/user/'030\ -\ IT\ Support'/'Backup\ Data'/Unraid/'VM\ Settings'/'$datestamp'/xml'
chmod -R 777 '/mnt/user/'030\ -\ IT\ Support'/'Backup\ Data'/Unraid/'VM\ Settings'/'$datestamp'/nvram'
sleep 5
exit

Here is SpaceInvaderOne's original script for comparison:

 

#!/bin/bash
#backs up
#change the location below to your backup location 
backuplocation="/mnt/user/test/"

# do not alter below this line
datestamp="_"`date '+%d_%b_%Y'`
dir="$backuplocation"/vmsettings/"$datestamp"
# dont change anything below here
if [ ! -d $dir ] ; then
 
			echo "making folder for todays date $datestamp"

			# make the directory as it doesnt exist
			mkdir -vp $dir
		else
			echo "As $dir exists continuing."
			fi

echo "Saving vm xml files"
rsync -a --no-o /etc/libvirt/qemu/*xml $dir/xml/
echo "Saving ovmf nvram"
rsync -a --no-o /etc/libvirt/qemu/nvram/* $dir/nvram/
chmod -R 777 $dir
sleep 5
exit

 

Was quite a bit of experimenting for a rookie but worth the lessons learned. If anybody see anything out of whack I'd appreciate it but the files are saving to my chosen path in a dated folder.  

maybe it's buried somewhere in this thread but I didn't see it (I admit I didn't read every single post)... but when I choose a predefined option of "Run Weekly" exactly what day/time does it run? I'm going to guess it's weekly based on the time/day I hit the "apply" button? But wanted to make sure.

 

3 minutes ago, jpotrz said:

maybe it's buried somewhere in this thread but I didn't see it (I admit I didn't read every single post)... but when I choose a predefined option of "Run Weekly" exactly what day/time does it run? I'm going to guess it's weekly based on the time/day I hit the "apply" button? But wanted to make sure.

 

Actually, IIRC, it’s based on settings>scheduler>fixed schedules. It’ll run whenever you have unRAID set to run weekly schedules.

  • Author
Actually, IIRC, it’s based on settings>scheduler>fixed schedules. It’ll run whenever you have unRAID set to run weekly schedules.
You also need to install the dynamic schedules plugin

Sent via telekinesis

Fully specify the config location.

why not just python3 /mnt/user/YouTube/youtube-dl ..?

  • Author

Probably in retrospect, this all makes perfect sense as user scripts doesn't execute any script through the shell, so any environment variables aren't set.  (This is also why you have to give items the full path in some cases vs when executing via a shell you don't have to)

Hello Team,

 

Hope you are all good. Am new to the unRaid world and have been liking every bit of it lately. @Squid I need your "help" with something.

 

I've added CA User Scripts together with Rclone docker from Wasesh. All is fine and working and I've had a backup running since yesterday to send data to my Onedrive (The backup is not huge but my internet is crap ...).

 

The sync is running in the background and wanted to stop it to let me have "normal' access to internet (since I'm caping my upload) but I don't see the button to stop the task. It's not a problem, I can kill the process via terminal, but I was wondering if you wanted to have a look if something is wrong or it's expected behaviour.

 

Let me know if you want and I'll send you whatever you need. Else, no biggie.

 

Cheers

  • Author

Any long running processes spawned by the actual script do not always wind up getting killed.  The plugin does attempt to kill off any child processes of the script, but depending upon what that child does (ie: spawns another child) then it does not always work.  Creating another script that has your pkill command in it should however work correctly.

 

EDIT:  Looked at the code, and there *might* be a bug in user scripts attempting to kill the childs.  Will have to investigate further.  How I'm using pkill doesn't jive with the man page on it.  Can't remember exactly how I came up with the syntax I'm using.

Edited by Squid

DUH ! I did not even thing about something like that. Thanks @Squid

Also user scripts doenst really see scripts running when they run a long time^^, but theres workarounds for that.

 

To kill rclone u can use that

ps -ef | grep "rclone" | grep -v 'grep' | grep -v 'mount' | awk '{ print $2 }' | xargs kill
 

 

it finds all rclones childs and kill all childs except the ones which work for mount (if u have that running).

Edited by nuhll

  • 2 weeks later...

There may be a valid reason why this is not done already, but if you edit the name of the script, could it also update the name of the corresponding folder in the user.scripts\scripts directory?

 

When I'm working on something I'll often call it something like "z docker testing" to put it at the end of the list.  When finished, I rename it, but it still stays at the bottom.  I'm guessing the plugin sorts the scripts list by folder name?

  • 2 weeks later...

Hi All,

 

I'm using the user scripts plugin to run a custom script every 5 minutes. I've set it up via the GUI, and I provided "*/5 * * * " in the custom field and applied the changes. However, I don't think my script is running every 5 minutes (I'm looking for a log file the script writes to and the log file doesn't get updated with the right timestamps). Am I missing any final steps to run the script periodically? /etc/cron.d/root file does seem to have an entry for my script....

 

Thanks!

@trurl, thanks for the catch. I had tried this manually using crontab -e and it worked fine then, but I think I missed a * when I copied it over to the GUI. So I didn't suspect this. Thanks again, and it seems to work fine now!

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.