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

2 hours ago, ICDeadPpl said:

Put 'bash' in front of the command. Like 'bash /boot/config/plugins/user.scripts/scripts/backup_onedrive/script'

Thanks ICDeadPpl, that worked. I've in one main script multiple sub user scripts I would like to launch. Is it possible to wait for one command to finish before launching the next? Currently both are started at the same time because of the "at now" command. I there a method to launch the second after the first is finished.

 

Thanks for the help

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

25 minutes ago, tschinz said:

Thanks ICDeadPpl, that worked. I've in one main script multiple sub user scripts I would like to launch. Is it possible to wait for one command to finish before launching the next? Currently both are started at the same time because of the "at now" command. I there a method to launch the second after the first is finished.

 

Thanks for the help

just do everything in one script, dont think there is a easy way. you could save a text file in the sub-scripts and wait for the file to appear in the main script

3 hours ago, Marcel40625 said:

Hey there,

 

i would like to know how i can mail the whole output of

 


rsync -av --delete --ignore-errors -e

 

as notification

 

thanks in advance

You could call '/usr/local/emhttp/webGui/scripts/notify' from your script, and have the message include the output of the rsync job.
The rsync output could be temporarily stored as a file, piped argument, named pipe or whatever.

Run the command '/usr/local/emhttp/webGui/scripts/notify' once without any arguments to see which there are for you to use.

You may want to check the notifications in Unradid Web UI "Settings/Notifications settings" so they are set to send email.

3 hours ago, Marcel40625 said:

Hey there,

 

i would like to know how i can mail the whole output of

 


rsync -av --delete --ignore-errors -e

 

as notification

 

thanks in advance

with the at command you can get an email

command | at now

 

10 minutes ago, ICDeadPpl said:

You could call '/usr/local/emhttp/webGui/scripts/notify' from your script, and have the message include the output of the rsync job.
The rsync output could be temporarily stored as a file, piped argument, named pipe or whatever.

Run the command '/usr/local/emhttp/webGui/scripts/notify' once without any arguments to see which there are for you to use.

You may want to check the notifications in Unradid Web UI "Settings/Notifications settings" so they are set to send email.

 

yeah but how can i attach the file or output from rsync to the notify command

 

/usr/local/emhttp/webGui/scripts/notify -i normal -s "Test" -d "Test" -m < test.txt 

 

does not work the content of the file is not showing in notification

2 minutes ago, Marcel40625 said:

 

yeah but how can i attach the file or output from rsync to the notify command

 


/usr/local/emhttp/webGui/scripts/notify -i normal -s "Test" -d "Test" -m < test.txt 

 

does not work the content of the file is not showing in notification

Try
 

MESSAGE=`rsync -av --delete --ignore-errors -e`
/usr/local/emhttp/webGui/scripts/notify -i normal -s "Test" -d "Test" -m "$MESSAGE"

 

51 minutes ago, ICDeadPpl said:

Try
 


MESSAGE=`rsync -av --delete --ignore-errors -e`
/usr/local/emhttp/webGui/scripts/notify -i normal -s "Test" -d "Test" -m "$MESSAGE"

 

 

thanks, but found out tail works

 

/usr/local/emhttp/webGui/scripts/notify -i normal -s "Test" -d "Test" -m "`tail logfile.log`"

 

  • Author
3 minutes ago, Marcel40625 said:

thanks, but found out tail works

 

One problem with all of this is that IF there's a double quote within the output of the tail then you'll either get weird results in the message, or the notify command itself will fail.

13 minutes ago, Squid said:

One problem with all of this is that IF there's a double quote within the output of the tail then you'll either get weird results in the message, or the notify command itself will fail.

thanks for the advice, but seems to work in this case :) and doesnt help ` ` for that?

Edited by Marcel40625

when i set my script to run daily what time will it run?

plugin: installing: https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg
plugin: downloading https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg
plugin: downloading: https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg ... done

+==============================================================================
| Installing new package /boot/config/plugins/user.scripts/user.scripts-2021.03.10-x86_64-1.txz
+==============================================================================

Verifying package user.scripts-2021.03.10-x86_64-1.txz.
Unable to install /boot/config/plugins/user.scripts/user.scripts-2021.03.10-x86_64-1.txz: tar archive is corrupt (tar returned error code 2)





----------------------------------------------------
user.scripts has been installed.
Copyright 2016-2020, Andrew Zawadzki
Version: 2021.03.10
----------------------------------------------------

plugin: user.scripts.plg installed
 

what is the problem when I install this plugin...pls help, thx

what is the problem when I install this plugin...pls help, thx

what is the problem when I install this plugin...pls help, thx a lot

 

 

  • Author

Try again.  Nothing wrong with that archive its trying to download.

4 hours ago, ajstaley33 said:

when i set my script to run daily what time will it run?

IIRC it will use the daily schedule set in Scheduler.

  • Author
4 minutes ago, wgstarks said:

IIRC it will use the daily schedule set in Scheduler.

Adjustable if you have The Schedules plugin installed

  • 2 weeks later...

I am looking for a script that does the following:

- check if cache is more than 60% ful 

- If so, then pause/stop all torrents in rtorrent and start mover

- if cache is less than 60% full do nothing

 

Anyone got a script like this?

On 3/25/2021 at 5:33 PM, ProphetSe7en said:

I am looking for a script that does the following:

- check if cache is more than 60% ful 

- If so, then pause/stop all torrents in rtorrent and start mover

- if cache is less than 60% full do nothing

 

Anyone got a script like this?

 

  • 2 weeks later...

Thanks. That covers one part of want I want. Still need to figure out how to stop/pause all torrents and then restart them after mover is done

11 minutes ago, ProphetSe7en said:

Thanks. That covers one part of want I want. Still need to figure out how to stop/pause all torrents and then restart them after mover is done

Without delving into whether it's possible to interact with rtorrent at that level, can't you just stop and start the docker with "docker stop <name-of-container>" and "docker start <name-of-container>" commands?

Probably, but stopping a torrent container can cause problems if a torrent is during dl or recently finished and no session has been saved the last 20 minutes. So I prefere to sett all active torrents in a pause state, run mover then resume all torrents

29 minutes ago, ProphetSe7en said:

Probably, but stopping a torrent container can cause problems if a torrent is during dl or recently finished and no session has been saved the last 20 minutes. So I prefere to sett all active torrents in a pause state, run mover then resume all torrents

docker pause <name-of-container> / docker unpause <name-of-container> then?

Hmm. That might work, need to test it first :)

Do you know if it is possible to issue the pause command only if cache is >60% full? No need to pause the container if mover wont run because of cache drive is less the 60% full.

 

I know mover can be started using script, and from mover settings it wont run if cache is less than 60%. But while doing this with a script it will cause rtorrent to pause/resume each time the script runs regardless of mover will be running or not

 

Edit: So I need to add the pause & unpause command to the mover script? Clearly the "docker pause/unpause rtorrentvpn" wont work like this, but what format should it be in to work?
 

if ( $percent > $moveAt ) {
  docker pause rtorrentvpn;
  exec("/usr/local/sbin/mover");
  docker unpause rtorrentvpn;
}

 

Edited by ProphetSe7en

1 hour ago, ProphetSe7en said:

Clearly the "docker pause/unpause rtorrentvpn" wont work like this, but what format should it be in to work?

I'm not at my machine at the moment, but somebody else would know better.  Your script would pause the docker (assuming that's the correct name), but I'm guessing it would unpause it straight away.

 

You'd need a second part to the script in an else block that checks if docker is paused and whether the mover is running.  If the mover has finished, unpause.  Something like...

 

if ( $percent > $moveAt ) {
  docker pause rtorrentvpn;
  exec("/usr/local/sbin/mover");
} else {
  if (!moverRunning && dockerIsPaused) {
    docker unpause rtorrentvpn;
  }
}

...although without researching I don't know how to check if the mover is running and a docker is paused - this is just to illustrate the concept.

6 hours ago, Cessquill said:

I'm not at my machine at the moment, but somebody else would know better.  Your script would pause the docker (assuming that's the correct name), but I'm guessing it would unpause it straight away.

 

You'd need a second part to the script in an else block that checks if docker is paused and whether the mover is running.  If the mover has finished, unpause.  Something like...

 

Hmm. I thought if I put the command under the "if" part of that script it would only be issued if the cache disk is >xx% ful, like the mover would in the script?

 

Maybe I am mistaken, but in this script everything under "if" only runs if the disk threshold is met?

 

#!/usr/bin/php
<?PHP

$moveAt = 70;    # Adjust this value to suit.

$diskTotal = disk_total_space("/mnt/cache");
$diskFree = disk_free_space("/mnt/cache");
$percent = ($diskTotal - $diskFree) / $diskTotal * 100;

if ( $percent > $moveAt ) {
  exec("/usr/local/sbin/mover");
}
?>

 

So I need to figure out on how to combine the script above with these commands.

 

docker exec comand

mover &&

docker exec comand (when mover is finished)

 

Not very elegant, but can I replace  

exec("/usr/local/sbin/mover");

 with

exec("/mnt/user/various/unRaid/script/mover.sh);

 

Then in the mover.sh I have the 

docker exec (command to pause all torrents)
mover &&
docker exec (command to start all torrents)

 

I get it to work, but then I dont have the threshold part in place.

Hey all,

This might be a more generic unix question but is there an easy way to enable timestamps for all logs that a "userscript" would produce?

quick googling i can do things like pipe my commands into various things to achieve this but i was wondering if there was an easy "turn on for everything in unraid" or maybe just "turn on for user scripts logs"?

Thanks in advance!

  • 3 weeks later...

Hello,

i hava a cron job problem.

I can't create a job with letters in day. This cron syntax 

40 7 * * Tue

sends an error in log "failed parsing crontab for user root: TUE" but 

40 7 * * 2 works

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.