Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to set up a scheduled task via anacron but I would like to do so in user mode. How can I achieve this?

share|improve this question

1 Answer

up vote 2 down vote accepted

You can set up a separate anacron instance to run in user mode. To do so create a .anacron folder in your home directory and in it two subfolders, etc and spool.

Then proceed to create a new anacrontab in your newly created ~/.anacron/etc folder with the following contents:

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

1   10    scriptname script.sh

where script.sh is the path to your script (or a one-liner, your choice). Configure the intervall and delay to your pleasure and save the file as anacrontab.

Then add the following line to your ~/.profile:

/usr/sbin/anacron -s -t ${HOME}/.anacron/etc/anacrontab -S ${HOME}/.anacron/spool

Your custom user mode anacron should be up and running on next login.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.