M
M
Monartoi2022-02-03 11:02:40
Task Schedulers
Monartoi, 2022-02-03 11:02:40

Why is postgresql backup script not running in Cron?

Good afternoon, I have a database backup script that runs fine from the CLI, but does not run through CRON, the logs do not show anything

Script

#!/bin/sh

# Backing up
docker exec -t pgstaff_postgres_1 pg_dumpall -c -U estaffuser | zstd  > /docker/backup/estaffdb_$(date +"%Y-%m-%>

# Rotating the logs, delete older than 31 days
find /docker/backup/estaffdb_* -mtime +31 -exec rm {} \;


crontab -e
0 3 * * * /root/scripts/estaff_backup.sh

CRON log

[email protected]:~# grep CRON /var/log/syslog
Feb 2 23:17:01 docker-hub01 CRON[4069163]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 3 00:17:01 docker-hub01 CRON[4074101]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 3 01:17:01 docker-hub01 CRON[4078986]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 3 02:17:01 docker-hub01 CRON[4083873]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)

ps -ef | grep cron
[email protected]:~# ps -ef | grep cron | grep -v grep
root 321 1 0 2021 ? 00:00:08 /usr/sbin/cron -f

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Monartoi, 2022-02-03
@Monartoi

The problem was solved by restarting the cron service: systemctl restart cron.service
It is strange of course why this is so

D
Dmitry, 2022-02-03
@q2digger

why did you show the log only up to 2 hours? ))
okay. is the script executable? Some kind of SELinux or AppArmor in the system is not weird? Have you tried changing sh to bash?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question