[Plugin] CA User Scripts


Recommended Posts

21 minutes ago, Squid said:

I tested with * * * * * on 6.9.2 and 6.11 and no issues with it (subject to 6.9 not adding the cron until it was started)

 

I’m on 6.10.3 and * * * * * only works after I disable and then re-enable the schedules.

 

I don’t remember having had this issue when I was on 6.9.x

Edited by Andrea3000
Link to comment
  • 3 weeks later...

Gents, I am using a script which is supposed to delete old footage from my CCTV cameras. 

 

The footage are stored in a folder named "/mnt/cctv/reolink/JardinHD" where "JardinHD" is the name of my camera. 

However, the camera will create some subfolders in there. 1 per yere, 1 per month and 1 per day. 

 

Therefore, the following script that I found on that thread doesn't seem to work:

 

#!/bin/bash
#name=Remove old surveillance recordings
#description=Removes old files and folders from cam1 and cam2 folder
#arrayStarted=true
find /mnt/cctv/reolink/JardinHD -type f -mtime +1 -delete
find /mnt/cctv/reolink/JardinHD  -type d -empty -delete

 

To run the test, I am trying to delete all footage older than 1 day. 

 

So how could I adapt that piece of script so it will handle the subfolders the camera is creating?

 

Thanks!!!

Link to comment
On 9/13/2022 at 10:29 AM, Squid said:

No.  Run a chmod after the rclone is finished or adjust the script parameters accordingly.

Thanks,

Ok but files are owned by root now. So I would need to run a chown and chmod after rclone then to end up with nobody:users and correct permissions for files on shares?

 

What do you mean by adjust the script parameters? rclone options?

Edited by frank-unr
Link to comment

I've been using USER SCRIPTS for sometime with success for a script tha tpowerdoens my server at 3 am each night. Something now has changed where my crontab isn't parsing (see syslog entry below). This script has been running for years but now it does not execute. The script runs fine when I hit run script from within USER SCRIPTS.  Tried a few different ways of formatting the crontab. No luck.

 

I reading through this thread I'm wondering if another plugin is interfering.

 

I run:

CA Auto Update Applications

Community Applications

Dynamix File Manager

Dynamix Local Master

Fix Common Problems

My Servers

Unassigned Devices

Unassigned Devices Plus

Unbalanced

 

Any ideas? Thanks ahead of time.

 

 

crond[1407]: failed parsing crontab for user root: 03*** /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/Powerdown_Unraid/script > /dev/null 2>&1

Link to comment

Linux 5.19.9-Unraid.
root@Tower:~# cat /etc/cron.d/root
# Generated docker monitoring schedule:
10 */6 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupda              te check &> /dev/null

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

# Generated mover schedule:
10 1 * * * /usr/local/sbin/mover &> /dev/null

# Generated plugins version check schedule:
10 */6 * * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/pluginchec              k &> /dev/null

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

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


# CRON for CA background scanning of applications
54 * * * * 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 cron schedule for user.scripts
0 3 * * * /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/pl              ugins/user.scripts/scripts/Powerdown_Unraid/script > /dev/null 2>&1

Link to comment

Hey!

I've been using user.scripts for triggering my backup script ever 3 days, but I noticed since I upgrade to unRAID v6.10.3 (I haven't check before this version bc it was working, I guess) that I get 2 behavior with it. One is doing what it's supposed to do via the run script button, another one when it's in running in background or via the run in background button. I'm more interested in the background method to automate my backups.

 

To be more specific, I'm using "rclone" and "restic" to backup everything to "storj" data center. rclone has its configuration working and stored as file in $HOME/.config/rclone/rclone.conf which is setted up automatically by another script, and a simple script to backup everything:

 

#!/bin/bash

echo $(rclone config file)

export RESTIC_PASSWORD=ABEAUTIFULPASSWORD
export RESTIC_REPOSITORY=rclone:storj:SERVER/LOCATION

echo "Starting backup..."
restic backup --exclude-file=/boot/config/plugins/user.scripts/scripts/backup_data/excludes.txt >
restic forget --keep-last 2 --prune
echo "Backup finished successfully"

 

Everything is working as intended with run script or by using bash /boot/config/plugins/user.scripts/scripts/backup_data/script

 

But when running in the backup I get this output from the script run

Script Starting Oct 01, 2022  12:04.54

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

Configuration file doesn't exist, but rclone will use this path: /.config/rclone/rclone.conf # <======= debug line to test if rclone detect the config file in the context. It should point to /root/.config/rclone/rclone.conf. Command "rclone config file"

Starting backup...
rclone: 2022/10/01 12:04:54 NOTICE: Config file "/.config/rclone/rclone.conf" not found - using defaults
rclone: 2022/10/01 12:04:54 Failed to create file system for "storj:cronos/backup": didn't find section in config file
Fatal: unable to open repo at rclone:storj:cronos/backup: error talking HTTP to rclone: Get "http://localhost/file-5577006791947779410": unexpected EOF
rclone: 2022/10/01 12:04:54 NOTICE: Config file "/.config/rclone/rclone.conf" not found - using defaults
rclone: 2022/10/01 12:04:54 Failed to create file system for "storj:cronos/backup": didn't find section in config file
Fatal: unable to open repo at rclone:storj:cronos/backup: error talking HTTP to rclone: Get "http://localhost/file-5577006791947779410": unexpected EOF
Backup finished successfully
Script Finished Oct 01, 2022  12:04.54

 

I noticed that when running in background, rclone doesn't use my configuration file (like it doesn't exists) and as fallback try using the /.config/rclone/rclone.conf which is not right as rclone default behavior should look up at $HOME/.config/rclone/rclone.conf

 

Any idea why I get 2 behavior with the script?

Thanks!

Link to comment

hi folks

i'm having a problem with the custom scheduling of the user scripts plugin.

after doing some trial and error, i found, that the day parameter of the cron doesn't seem to work, or that i'm using it wrongly. (i assume it's the last one)

script works and gets executed manually and also automatically via cron, whejn the day parameter is set to * .

when i set it to anything other, the script is not executed.

 

example:

32 9 1-7 * * -> works, script is being executed

32 9 1-7 * wed -> does not work

32 9 1-7 * 3 -> does not work

and with 1,2,3,4,5,6,7 instead did not change anything, sadly

 

 

if anyone is able to help, would make me pretty happy. use case is, that the script should be executed on every first monday every month. -> https://crontab.guru/#0_0_1-7_*_mon (copied it from there to minimize errors) but this is not being executed :(

i'm running unraid 6.11.0

update_cron and rebooting did not solve this issue

 

 

 

Edited by spidobot
Link to comment
1 hour ago, spidobot said:

if anyone is able to help, would make me pretty happy. use case is, that the script should be executed on every first monday every month

Try this

0 0 * * 1 [[ $(date +%e) -le 7 ]] && 

First Monday of every month at midnight

Link to comment
5 minutes ago, Squid said:

Try this

0 0 * * 1 [[ $(date +%e) -le 7 ]] && 

First Monday of every month at midnight

 

thanks for the quick reply! this did the trick.

when entering "cat /etc/cron.d/root i learned why to enter it that way. guess you learn something new everyday :)

 

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

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

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

# Generated parity check schedule:
30 0 * * 1 [[ $(date +%e) -le 7 ]] && /usr/local/sbin/mdcmd check  &> /dev/null || :
# Generated plugins version check schedule:
10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /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 1 * * 1 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1
# Generated cron settings for plugin autoupdates
0 1 * * 1 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1

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

# Generated cron schedule for user.scripts
36 10 1-7 * WED /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/ServerReboot/script > /dev/null 2>&1
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.