[Plugin] CA User Scripts


Recommended Posts

I have all mine goto a Cache/SSD drive. No spin ups required. 😃

 

I have a few shares

(Uploads)

   ../incoming

   ../outgoing

(Movies)

(Tv)

 

When ever I rip a movie or tv show I always send it to my (Upload) share. Then unraid via user scripts checks that upload folder and rips thru handbrake and a few other processes and then it places it in outgoing folder which FileBot looks at and then renames things and places it either in a (TV) or (Movie) share. Mover runs in the AM when my Plex Docker spools up to check my drives for new stuff moves the files onto the Protected Array off the SSD drive. 

 

My scripts run every 30 minutes so I don't have to Babysit, but the final drop to my Array/Spinner drives are at 6AM along with Plex. 

Link to comment

Hey all,

 

I have created my script for shutdown my server at 00 every days.

 

My Script is :

/usr/local/sbin/powerdown

 

My Custom Schedule file is :

 

# Generated cron schedule for user.scripts
00*** /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/Shutdown Schedule/script > /dev/null 2>&1

 

In my dashbord of unraid :

 

image.thumb.png.8cc1ed64f0e6ec6b7d879c0bafbd4b5e.png

 

What should I do after that? because apparently my server does not stop.

 

Thank You.

Link to comment
14 minutes ago, snake382 said:

Hey all,

 

I have created my script for shutdown my server at 00 every days.

 

My Script is :

/usr/local/sbin/powerdown

 

My Custom Schedule file is :

 

# Generated cron schedule for user.scripts
00*** /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/Shutdown Schedule/script > /dev/null 2>&1

 

In my dashbord of unraid :

 

image.thumb.png.8cc1ed64f0e6ec6b7d879c0bafbd4b5e.png

 

What should I do after that? because apparently my server does not stop.

 

Thank You.

Your custom cron is wrong. There must be spaces between each part.

Link to comment

Hi all, I have done some reading and searching and can't find a clear answer.  Is there a way outside of writing it a script to get a notification that the script ran and completed successfully/failed? I use this to run some very basic rclone backups, but have no way of knowing if it ran successfully or failed.  If it did run successfully, I'd love to see the log of what was uploaded rclone puts out under the verbose command.  If it fails I'd like to know that as well so I don't assume it completed.  Is this a built in feature I am just missing?  I believe I read that it possible to get an notification, but it needs to be written in the script, but I am not familiar with writing scripts (outside of simple rclone commands).  

 

Thanks!

-Jason

Link to comment

I don't intend to have the plugin send out a notification after a script runs.

 

Rather, you'll have to do some homework, and then utilize the notify command

root@ServerA:~# /usr/local/emhttp/plugins/dynamix/scripts/notify
notify [-e "event"] [-s "subject"] [-d "description"] [-i "normal|warning|alert"] [-m "message"] [-x] [-t] [add]
  create a notification
  use -e to specify the event
  use -s to specify a subject
  use -d to specify a short description
  use -i to specify the severity
  use -m to specify a message (long description)
  use -x to create a single notification ticket
  use -t to force send email only (for testing)
  all options are optional

notify init
  Initialize the notification subsystem.

notify smtp-init
  Initialize sendmail configuration (ssmtp in our case).

notify get
  Output a json-encoded list of all the unread notifications.

notify archive file
  Move file from 'unread' state to 'archive' state.

And execute the appropriate command based upon say the exit code of your rclone command

Link to comment
48 minutes ago, Andiroo2 said:

User Scripts can't talk to docker containers with their own IPs anymore, right?  Unless I set up VLANs, etc?  I was using a script to query my UPS, but I can't upload the results to InfluxDB anymore since it's on its own IP now.  

With "br0" it should could?! Atleast thats how i do it.

Edited by nuhll
Link to comment

Anyone a idea why my script doesnt get run anymore?

 

*/5 * * * *

 

Its running since the start of the day, but since then it doesnt get recalled. Its an upload script which shoudl stop itself after PCs go online... 

 

What can be the problem when the script doenst get run anymore? (I see in log it is working, but i see it dont get run every 5 min)

Edited by nuhll
Link to comment

So, it seems that sometimes scripts dont get rerun when they running, and sometimes they do.

 

I want to avoid that problem by running another script:

 

#!/bin/sh

### Here you can enter your hosts IP addresses, you can add as much was u want, but then u need to also specify them later in code
host=192.168.86.42
#host2=192.168.86.48
#host3=192.168.86.154

 

### Hosts

### Ping 3 hosts
ping -c 1 -W1 -q $host > /dev/null
      if [ $? == 0 ]; then

###  Check if script already run 
if [[ -f "/mnt/user/appdata/other/speed/rclone_killed" ]]; then
logger ""$(date "+%d.%m.%Y %T")"" rclone bereits gekillt.
exit

else

touch /mnt/user/appdata/other/speed/rclone_killed

fi
###

logger min. 1 Ping erfolgreich, rclone gekillt.

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


else
logger Ping nicht erfolgreich, rclone kann wieder starten.
rm -f /mnt/user/appdata/other/speed/rclone_killed

exit

fi

 

problem here is, that this scripts run forever and i dont know why. Ive set everywhere a exit, so this script should stop at some pojnt... why not?

Link to comment
  • 3 weeks later...

I have a question about how scripts are executed. If I have several "Scheduled Daily" scripts are they executed in a particular order? Are they executed serially, one after another, or in parallel? The reason I ask is I have one daily script that is restarting a Docker container that one of the other daily scripts is dependent upon.

Link to comment
17 minutes ago, Taddeusz said:

I have a question about how scripts are executed. If I have several "Scheduled Daily" scripts are they executed in a particular order? Are they executed serially, one after another, or in parallel? The reason I ask is I have one daily script that is restarting a Docker container that one of the other daily scripts is dependent upon.

I think the correct way of handling your exact case is to merge the two scripts, so you can be positive that the first action is complete before starting the second action. Ideally you could issue the restart command, then do a conditional loop checking to verify it's running again before moving on.

 

I don't really know how for sure how cron tasks are handled, I think they are all queued up at the same time and attempt to run in parallel.

Link to comment
12 minutes ago, jonathanm said:

I think the correct way of handling your exact case is to merge the two scripts, so you can be positive that the first action is complete before starting the second action. Ideally you could issue the restart command, then do a conditional loop checking to verify it's running again before moving on.

 

I don't really know how for sure how cron tasks are handled, I think they are all queued up at the same time and attempt to run in parallel.

I was kind of thinking that myself. It's really the only way I can guarantee the order of execution.

Link to comment
  • 2 weeks later...

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.