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.

Unraid Plugin Have PLG call update_cron in pre/post setup

Featured Replies

I'm putting together a plugin for Unraid to monitor how much time my drives spend in standby. I've got the plugin working and my next steps is to polish it a bit, but I can't figure out how to make it install the cron entry during install.

 

You can find the repo and PLG here:  Github - DriveStandbyMonitor

 

I've tried to call it directly from a pre and post install section in the PLG, I've also tried a PHP variation I found in one of the other plugins, but no luck. Can anyone shine some light on this?

Edited by EldonMcGuinness

9 hours ago, EldonMcGuinness said:

I'm putting together a plugin for Unraid to monitor how much time my drives spend in standby. I've got the plugin working and my next steps is to polish it a bit, but I can't figure out how to make it install the cron entry during install.

 

You can find the repo and PLG here:  Github - DriveStandbyMonitor

 

I've tried to call it directly from a pre and post install section in the PLG, I've also tried a PHP variation I found in one of the other plugins, but no luck. Can anyone shine some light on this?

This is the process I use to create a cron entry in my plugins is below, which is included in the Wrappers.

 

Looking at your plg, I dont see a reason why it is not working. Here is an example of my plugins plg https://github.com/SimonFair/USB_Manager/blob/main/usb_manager.plg but I dont create cron in the plg. Does the file get created on the boot drive when you install?

 

function parse_cron_cfg($plugin, $job, $text = "") {
  $cron = "/boot/config/plugins/$plugin/$job.cron";
  if ($text) file_put_contents($cron, $text); else @unlink($cron);
  exec("/usr/local/sbin/update_cron");
}

 

 

  • Author

Yes, the file is there after the install and to make things even weirder, I can open a terminal after the install, run update_cron, and it will install the cron just fine.

 

I'll give your snippet a try. I'm looking at your plug and I'm not seeing that snippet, do you not call it during the install? 

 

Basically what I'm trying to achieve is to have the cron job get installed during the install process.

Edited by EldonMcGuinness

9 minutes ago, EldonMcGuinness said:

Yes, the file is there after the install and to make things even weirder, I can open a terminal after the install, run update_cron, and it will install the cron just fine.

 

I'll give your snippet a try. I'm looking at your plug and I'm not seeing that snippet, do you not call it during the install? 

 

Basically what I'm trying to achieve is to have the cron job get installed during the install process.

That is only used to create the cron file from gui pages. You don't need for your plugin, it was an example.

 

update_cron should just work if the file exists in /boot/config/plugin/YourPluginName/name.cron.

 

do you see you entry in here: cat /etc/cron.d/root

  • Author

Yup, I see the file and again I can just call update_cron after the install via the terminal, or reboot the server, and the cron gets installed as it should. It just seems like you can't call update_cron during pre-/post-install. I don't need to create a cron via the pages, at least not yet, just a single cron that should be setup when the plugin is installed. By the way, did not know one could use fontawesome tags for icons! Cheers for that, though I do wish they would update to say FA6!

17 minutes ago, EldonMcGuinness said:

Yup, I see the file and again I can just call update_cron after the install via the terminal, or reboot the server, and the cron gets installed as it should. It just seems like you can't call update_cron during pre-/post-install. I don't need to create a cron via the pages, at least not yet, just a single cron that should be setup when the plugin is installed. By the way, did not know one could use fontawesome tags for icons! Cheers for that, though I do wish they would update to say FA6!

Strange just installed an seems to be find and as you say doesnt update cron, but remove removes it. Will look to see if I can see an option to fix.

28 minutes ago, EldonMcGuinness said:

Yup, I see the file and again I can just call update_cron after the install via the terminal, or reboot the server, and the cron gets installed as it should. It just seems like you can't call update_cron during pre-/post-install. I don't need to create a cron via the pages, at least not yet, just a single cron that should be setup when the plugin is installed. By the way, did not know one could use fontawesome tags for icons! Cheers for that, though I do wish they would update to say FA6!

Maybe try

 

<!--
DSM background start script.
-->
<FILE Name="/tmp/start_DrvStdbyMon" Mode="0770">
<INLINE>
#!/bin/bash

update_cron

# Remove the background start script.
rm -f /tmp/start_DrvStdbyMon 2>/dev/null
</INLINE>
</FILE>


and add post script.

at -M -f /tmp/start_DrvStdbyMon now 2>/dev/null

 

  • Author

Good find! I was able to get it working by modifying the at command and doing:

at -M -f /tmp/start_DrvStdbyMon now + 1 2>/dev/null

I think it is a bit of a race condition that might be happening.

Edited by EldonMcGuinness

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.