0

here is the crontab for root on my CentOS7 :

# crontab -l
# Lines below here are managed by Salt, do not edit
# SALT_CRON_IDENTIFIER:CLEANCORE
0 * * * * /var/lib/scality/cleancore/clean_core.bash --log --pattern "/var/tmp/core-\%e-\%p-\%t" --maxsize 10G --keep 3
0 18 * * */2 /root/shl/synchro_ADN_To_Scality.sh

The script /root/shl/synchro_ADN_To_Scality.sh did not run last night :

# ls ~/log | grep synchro_ADN_To_Scality-PAR-ADN-SYN01-20230130-18H
# systemctl status crond
● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2023-01-26 15:58:44 CET; 4 days ago
 Main PID: 775 (crond)
   CGroup: /system.slice/crond.service
           └─775 /usr/sbin/crond -n

Jan 26 15:58:44 my-server systemd[1]: Started Command Scheduler.
Jan 26 15:58:45 my-server crond[775]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 0% if used.)
Jan 26 15:58:45 my-server crond[775]: (CRON) INFO (running with inotify support)
Jan 30 10:32:01 my-server crond[775]: (root) RELOAD (/var/spool/cron/root)
# journalctl -u crond
-- Logs begin at Thu 2023-01-26 15:58:39 CET, end at Tue 2023-01-31 10:01:02 CET. --
Jan 26 15:58:44 my-server systemd[1]: Started Command Scheduler.
Jan 26 15:58:45 my-server crond[775]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 0% if used.)
Jan 26 15:58:45 my-server crond[775]: (CRON) INFO (running with inotify support)
Jan 30 10:32:01 my-server crond[775]: (root) RELOAD (/var/spool/cron/root)
# grep "Jan 30 18:" /var/log/cron
Jan 30 18:00:01 my-server CROND[48393]: (root) CMD (/var/lib/scality/cleancore/clean_core.bash --log --pattern "/var/tmp/core-%e-%p-%t" --maxsize 10G --keep 3)
Jan 30 18:01:01 my-server CROND[48414]: (root) CMD (run-parts /etc/cron.hourly)
Jan 30 18:01:01 my-server run-parts(/etc/cron.hourly)[48414]: starting 0anacron
Jan 30 18:01:01 my-server run-parts(/etc/cron.hourly)[48423]: finished 0anacron
Jan 30 18:01:01 my-server run-parts(/etc/cron.hourly)[48414]: starting scality-clean-event-logs
Jan 30 18:01:01 my-server run-parts(/etc/cron.hourly)[48430]: finished scality-clean-event-logs
Jan 30 18:01:01 my-server run-parts(/etc/cron.hourly)[48414]: starting scality-clean-trace-logs
Jan 30 18:01:01 my-server run-parts(/etc/cron.hourly)[48437]: finished scality-clean-trace-logs

And here is the synchro_ADN_To_Scality.sh script :

#!/usr/bin/env bash

logFilePrefix=$(basename $0 .sh)
logFileSuffix=$(date +%Y%m%d-%HH%MM%S).log
echo "=> Starting <$HOME/shl/synchro_with--delete-during_PAR-ADN-SYN01.sh>, you can following this script in <$HOME/log/$logFilePrefix-PAR-ADN-SYN01-$logFileSuffix>."
$HOME/shl/synchro_with--delete-during_PAR-ADN-SYN01.sh >$HOME/log/$logFilePrefix-PAR-ADN-SYN01-$logFileSuffix 2>&1
logFileSuffix=$(basename $0 .sh)_$(date +%Y%m%d-%HH%MM%S).log
echo "=> Starting <$HOME/shl/synchro_with--delete-during_PAR-ADN-SYN02.sh>, you can following this script in <$HOME/log/$logFilePrefix-PAR-ADN-SYN02-$logFileSuffix>."
$HOME/shl/synchro_with--delete-during_PAR-ADN-SYN02.sh >$HOME/log/$logFilePrefix-PAR-ADN-SYN02-$logFileSuffix 2>&1

EDIT0 :

# grep -r /root/shl/synchro_ADN_To_Scality.sh /var/log/cron
# grep /root/shl/synchro_ADN_To_Scality.sh /var/spool/mail/root
#

EDIT1 : My crontab was missing a newline after the last job. It works fine now.

What am I doing wrong ?

3
  • 1
    As explained in the linked duplicate: fairly typical when the last entry in a crontab doesn't run: missing newline
    – diya
    Jan 31, 2023 at 9:29
  • @diya OK, I just added a newline at the end of the crontab file and rescheduled the task for 11am (France TZ). I'll have to wait 20 minutes to check if it works.
    – SebMa
    Jan 31, 2023 at 9:39
  • @diya It worked :) Do you mind converting your two comments to an answer so I can accept and upvote it ?
    – SebMa
    Jan 31, 2023 at 10:05

1 Answer 1

0
  1. Make sure that cron run script by grep -r '/root/shl/synchro_ADN_To_Scality.sh' /var/log/cron to see if cron run that script
  2. Make sure that script synchro_ADN_To_Scality.sh run properly by check output log of script or error email from cron
3
  • Hi, thanks for your help. Please see my EDIT0.
    – SebMa
    Jan 31, 2023 at 9:35
  • Look like that cron not pick script synchro_ADN_To_Scality.sh Please check if /var/log/cron is exists and try grep 'synchro_ADN_To_Scality.sh' /var/log/cron again
    – Jimmy
    Jan 31, 2023 at 9:46
  • /var/log/cron does exist. It was in fact a missing newline at the end of my /var/spool/cron/root file.
    – SebMa
    Jan 31, 2023 at 10:03

Not the answer you're looking for? Browse other questions tagged .