Add anacron as optional schedule task handler


Sunri5e

Recommended Posts

I only use unRAID as hypervisor for my gaming machine and dont have it 24/7 running.

 

Currently you are using crontab to run scheduled tasks but if my system is not running at this time, the cronjob is not executed.

 

It would be nice if you could implement anacron as second choice.

 

#/bin/bash

# Concatenate the current set of plugin-specific cron files
# into single system crontab.

ENTRIES=$(cat /boot/config/plugins/*/*.cron 2>/dev/null)
if (($? != 0)); then
  crontab -c /etc/cron.d -d
else
  echo "$ENTRIES" | crontab -c /etc/cron.d -
fi

Link to comment

(I'm not responsible for any damage)

I made a manual anacron setup via go script:

 

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &

# copy anacron binary and set permissions
cp /boot/config/anacron/anacron /usr/sbin/
chmod 755 /usr/sbin/anacron

# start anacron if all is ready
if [ -x /usr/sbin/anacron -a -f /boot/config/anacron/anacrontab ]; then
/usr/sbin/anacron -s -t /boot/config/anacron/anacrontab -S /boot/config/anacron/spool/
fi

 

 

# /etc/anacrontab: configuration file for anacron

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1       5       cron.daily              nice run-parts /boot/config/anacron/cron.daily
7       25      cron.weekly             nice run-parts /boot/config/anacron/cron.weekly
@monthly 45     cron.monthly            nice run-parts /boot/config/anacron/cron.monthly

 

All you need is an anacron binary in /usr/sbin/ and to create all needed directories/your anacron scripts.

 

Link to comment
  • 3 years 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.