Advertising

Welcome to SparkyLinux forums
Zapraszamy również na polsko-języczne Forum https://forum.linuxiarze.pl

Anacron job is not executed

Started by wimduk, March 24, 2021, 02:09:00 PM

Previous topic - Next topic

wimduk

Dear reader,

I try to setup a personal anacron environment to execute scrips on a regular basis, until now I am not successfull to get it up and working working.
I have read and tried tons of documents without success. My last basis of the personal anacron setup is this document :
https://dr-luthardt.de/linux.htm?tip=anacron

My computer
Linux wim-pc 4.19.0-14-686 #1 SMP Debian 4.19.171-2 (2021-01-30) i686 GNU/Linux

My anacron environment
I have the following directories                     files
/home/wim/.anacron                          anacrontab
/home/wim/.anacron/timestamps       empty
/home/wim/.anacron/user.daily              0anacron, copyfin
/home/wim/.anacron/user.montly      empty
/home/wim/.anacron/user.weekly      empty

Anacron testing and starting
I have setup my anacron environment with the following commands
1. /usr/sbin/anacron -fn -t /home/wim/.anacron/anacrontab \ -S /home/wim/.anacron/timestamps   # setup personal anacron environment, no warnings.
2. /usr/sbin/anacron -T -t  /home/wim/.anacron/anacrontab \ -S /home/wim/.anacron/timestamps   # test personal anacron environment, no warnings.
3. /usr/sbin/anacron -s -t /home/wim/.anacron/anacrontab -S /home/wim/.anacron/timestamps    # activate personal anacron environment, no warnings.

Be aware :I had to add "/usr/sbin/" in front of the command, otherwise "anacron" was not found.

Troubleshoot
Upfront : I have set with "chmod 777" all directories and scripts to full access for all users and groups.
1. I ran the copyfin script by hand /home/wim/.anacron/user.daily/copyfin and the output was as expected; the file "copy_financieel.txt" was created.
   So my first conclusion is that the script is Ok
2. To narrow the problem area I copied the copyfin script to the "/etc/cron.daily" directory and restarted the machine, but NOTHING happened.
   I waited long after the aptitude script was executed before looking for the output of the copyfin script.

So at the moment I am lost and would like to ask the SparkyLinux community for help!
With many thanks in advance for everyone who is looking after ma problem

Kind regards, wimduk
wim.dukker@gmail.com

Scripts
-------------------------------------------------------------------
anacrontab
# See anacron(8), anacrontab(5) and run-parts(8) for details.
# Users anacrontab
#
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=wim
#
# Personal entries for user wim
1  5  cron.personal  run-parts -v /home/wim/.anacron/user.daily
#
# eof
-------------------------------------------------------------------
0anacron
#!/bin/sh
#
# anacron's cron script
#
# This script updates anacron time stamps. It is called through run-parts
# either by anacron itself or by cron.
#
# The script is called "0anacron" to assure that it will be executed
# _before_ all other scripts.

test -x /usr/sbin/anacron || exit 0
/usr/sbin/anacron -S /home/wim/.anacron/timestamps -u -t /home/wim/.anacron/anacrontab user.daily
-------------------------------------------------------------------
copyfin
#!/bin/bash
# Copy_Infobase_Financieel to /home/wim/Dropbox
#
#Local:  rsync [OPTION...] SRC... [DEST]
#options
# -v, --verbose increase verbosity
# -u, --update skip files that are newer on the receiver
# -r, --recursive recurse into directories
# -b, --backup make backups (see --suffix & --backup-dir)
#
# ---------------------------------------------------------
# Variabelen
PATH=/sbin:/bin:/usr/sbin:/usr/bin
Bron=/media/wim/Data/00_Infobase_Data/00_Financieel/
Doel=/home/wim/Dropbox/00_Financieel/
Rapport=/home/wim/Cron_Rapporten
echo $Bron
echo $Doel
#
# ---------------------------------------------------------
#
echo # --------------------------------------------------------- >> $Rapport/copy_financieel.txt
rsync -urv $Bron $Doel >> $Rapport/copy_financieel.txt
#
# ---------------------------------------------------------

Questions
Q1 why is the lshw command not available in the SparkyLinux /bin directory?

wimduk

UPDATE

I think anacron is NOT running on SparkeLinux. I updated the 0anacron script to check if this script is executed during the startup phase. But it is NOT!
The file  /home/wim/0anacron.txt is NOT available after a start or a restart of the machine

#!/bin/sh
#
# anacron's cron script
#
# This script updates anacron time stamps. It is called through run-parts
# either by anacron itself or by cron.
#
# The script is called "0anacron" to assure that it will be executed
# _before_ all other scripts.
echo "0anacron is executed" >> /home/wim/0anacron.txt
test -x /usr/sbin/anacron || exit 0
anacron -u cron.daily

MoroS

#2
You can check the service status with:
systemctl status anacron

That being said, scripts in /usr/sbin are not intended to be used by a normal user and are not on the PATH.
There's no such thing as "impossible". :)

MoroS

Ok, let's dive into details a bit: anacron is one of many cron implementations, that are not supposed to be used directly. You want cron jobs to be portable from system to system, so you use normal cron expression, not implementation-specific. Another system can have another implementation, like vixie-cron or cronie and then your scripts might not work or you might not be able to install them using anacron (which is not there, because there's something else).

What you want to do, is to create a normal cron job as a normal user. Sparky uses Debian's policy on this (no modifications of our own), so you can just use crontab to manage your jobs. You can try following any Debian cron tutorial out there, like this one for example: https://vitux.com/how-to-setup-a-cron-job-in-debian-10/
There's no such thing as "impossible". :)

View the most recent posts on the forum