Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

anacron does not execute my bash script

Tags:

linux

cron

For testing I wrote this bash script

#! /bin/bash
echo "Time: $(date)" >> /home/benno/Desktop/anacron

which I want to execute with anacron on a daily basis. I therefore added the following line to my /etc/anacrontab file

1       0      benno                    /home/benno/Desktop/anacronCheck.sh

However, when I run the command anacron -n (running all jobs without time delay) nothing happens.

Any suggestions why anacron is not running my bash script?

like image 365
benno Avatar asked Feb 04 '26 15:02

benno


1 Answers

The solution was to run anacron via the following command

sudo anacron -fdn

anacron needs root privileges otherwise it wont do anything, hence sudo. The -f and -n parameter together force all jobs to be executed immediately disregarding of timestamps and delays. -d prevents anacron from forking into the background -> error messages will otherwise not be printed to the console.

like image 83
benno Avatar answered Feb 06 '26 11:02

benno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!