If you want to send us your comments, please do so. Thanks
More on comments
Run a command
if the computer is running
Always put the code in a script
Start the script with
#! /bin/bash
Then call the script from anacron. If you do not use a script you can get something like
/bin/sh: 1: [[: not found
in the case you used an [[ statement for example
On servers do not user anacron, use cron
Put scripts in a file in /etc/cron.daily, /etc/cron.weekly or /etc/cron.monthly
systemctl restart anacron.service
File | Remark |
---|---|
/home/user/.local/anacrontab | For user specific entries |
/etc/anacrontab | Put the non user entries in this file |
/etc/cron.d/anacron | |
/etc/default/anacron | |
/etc/init.d/anacron |
Syntax: VAR=VALUE
Command | Remark |
---|---|
SHELL=/bin/bash | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
HOME=/root | Or used in crontab only? |
LOGNAME=root | Used in the From: field the e-mail. Username, may not be changed. Or used in crontab only? |
MAILTO=user | User to whom the output of anacron has to be mailed |
START_HOURS_RANGE=10-12 | In this time frame jobs are started. If missed they are skipped for that day |
RANDOM_DELAY=delaytime | 0: off. Other value: Add a delay of 0 to delaytime minutes to the delay time (see commands section) |
Option | Explanation |
---|---|
period | days |
delay | minutes |
job-identifier | Make up yourself. “ ” (space) and “/” are not allowed |
command | Any shell command or script. Field separation with blank spaces or tabs |
Syntax | Remark |
---|---|
period delay job-identifier command | period is in days |
monthly delay job-identifier command | daily nor weekly are possible. Use the previous syntax with a period of 1 or 7 |
Place a '\' and continue the command on the next line
4 10 backupSomething cp /home \ /backup
Short, -, nor long, --, options are allowed. There will be an error message: “/bin/sh: 0: Illegal option -”, (long --)
Solution: write a script and have anacron run it
# Comment 4 10 backupSomething cp /home /backup monthly 20 backupSomething cp /home /backup # An other comment
Command | Explanation |
---|---|
anacron -T | Test the anacrontab file |
anacron -nf | Run all commands now regardless the timestamp |
Check the date when an anacron job has last run in /var/spool/anacron/jobname. The format is yyyymmdd (may depend on the locale setting)
anacron needs root privileges to run. You can run it in user mode. Do
@reboot /usr/sbin/anacron -s -t $HOME/.local/anacrontab -S $HOME/.local/spool/anacron @hourly /usr/sbin/anacron -s -t $HOME/.local/anacrontab -S $HOME/.local/spool/anacron @daily /usr/sbin/anacron -s -t $HOME/.local/anacrontab -S $HOME/.local/spool/anacron
@hourly runs at every full hour: [0-24]:00
@daily runs very day at midnight: 0:00
Why would anacron not be running
Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy
RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2022 Webevaluation.nl and the authors
Changes reserved.