Advertising

Welcome to SparkyLinux forums
Zapraszamy również na polsko-języczne Forum Linuxiarze.pl

Author Topic: Anacron job is not executed  (Read 484 times)

Offline wimduk

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Anacron job is not executed
« on: March 24, 2021, 02:09:00 pm »
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?

Offline wimduk

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Anacron job is not executed, Anacron is NOT executed I think
« Reply #1 on: March 25, 2021, 05:43:44 pm »
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
« Last Edit: March 25, 2021, 05:50:25 pm by wimduk »

Offline MoroS

  • Sr. Member
  • ****
  • Posts: 290
  • Karma: 0
  • Problem solver ;)
Re: Anacron job is not executed
« Reply #2 on: March 25, 2021, 06:03:17 pm »
You can check the service status with:
Code: [Select]
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.
« Last Edit: March 25, 2021, 06:05:13 pm by MoroS »
There's no such thing as "impossible". :)

Offline MoroS

  • Sr. Member
  • ****
  • Posts: 290
  • Karma: 0
  • Problem solver ;)
Re: Anacron job is not executed
« Reply #3 on: March 25, 2021, 06:16:56 pm »
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". :)