User-specific anacrontab?

5,703

Solution 1

anacron -t ${HOME}/etc/anacrontab -S ${HOME}/var/spool/anacron
  • -t anacrontab (eg. ${HOME}/etc/anacrontab )
  • -S spooldir (eg. ${HOME}/var/spool/anacron

Add the command in your ~/.profile to execute when you login, or put it in a hourly cronjob to run on its own.

You don't need to worry about anacron running all its scripts every hour if you put it in cron, as it keeps its own timestamps of its last run in the spool directory.

See man anacrontab for more info on making your own anacrontab file.

Solution 2

Depending on the volume of affected scripts, you may also just use sudo -u with the command in your anacrontab file or directory.

Example with bash:

sudo -u ${USER_TO_RUN_AS} bash -l -c "echo 'Replace this echo with some more useful logic.'"

This saves you from having to maintain two additional files.

Share:
5,703

Related videos on Youtube

Ryan C. Thompson
Author by

Ryan C. Thompson

Updated on September 17, 2022

Comments

  • Ryan C. Thompson
    Ryan C. Thompson almost 2 years

    I can use crontab -e as a normal user to edit my user crontab. Does anacron have any similar feature for individual non-admin users, or does it only have a system-wide anacrontab?

    • Martin Schröder
      Martin Schröder about 9 years
      @gavenkoa: That blog has rottet away.
  • Prix
    Prix almost 14 years
    glad you managed it :) anything get back to us
  • Thomas
    Thomas over 6 years
    I think the idea OP was going for was if you aren't the admin.