ricardodfg
(usa Debian)
Enviado em 12/04/2024 - 08:14h
Olá bom dia,
Estou com problema para execução do crontab no proxmox.
Segue agendamento crontab -e
30 12 * * * /backup.sh
00 21 * * * /backup.sh
arquivo backup.sh
====================================
#!/bin/bash
INICIO=`date +%d/%m/%Y-%H:%M:%S`
LOG=/var/log/rsync/`date +%Y-%m-%d`.txt
echo " " >> $LOG
echo " " >> $LOG
echo "| ------ ------ ------ ------ ------ ------ -----------" >> $LOG
echo " Sincronizacao iniciada em $INICIO" >> $LOG
rsync -avz /mnt/pve/files_drive/ /mnt/pve/backup_drive/ >> $LOG
FINAL=`date +%d/%m/%Y-%H:%M:%S`
echo " Sincronizacao Finalizada em $FINAL" >> $LOG
echo "| ------ ------ ------ ------ ------ ------ -----------" >> $LOG
echo " " >> $LOG
echo " " >> $LOG
===========================================
já foi feito chmod 777 backup.sh e também o chmod +x backup.sh
se eu executar o ./backup.sh direto no terminal, funciona normalmente, porém pelo cron não.
Arquivo /etc/crontab
============================================
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.daily; }
47 6 * * 7 root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.weekly; }
52 6 1 * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.monthly;
=============================================================
já tentei de tudo, porém no log do proxmox no horário agendado aparece as seguintes informações:
Apr 11 12:30:01 hyp CRON[4049281]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Apr 11 12:30:01 hyp CRON[4049282]: (root) CMD (/backup.sh)
Apr 11 12:30:01 hyp CRON[4049281]: pam_unix(cron:session): session closed for user root
Apr 11 12:30:01 hyp postfix/pickup[4048163]: D431D140FE7: uid=0 from=<root>
Apr 11 12:30:01 hyp postfix/cleanup[4049286]: D431D140FE7: message-id=<@hyp.local>
Apr 11 12:30:01 hyp postfix/qmgr[894]: D431D140FE7: from=<root@hyp.local>, size=586, nrcpt=1 (queue active)
Apr 11 12:30:01 hyp postfix/local[4049288]: error: open database /etc/aliases.db: No such file or directory
Apr 11 12:30:01 hyp postfix/local[4049288]: warning: hash:/etc/aliases is unavailable. open database /etc/aliases.db: No such file or directory
Apr 11 12:30:01 hyp postfix/local[4049288]: warning: hash:/etc/aliases: lookup of 'root' failed
Apr 11 12:30:01 hyp postfix/local[4049288]: D431D140FE7: to=<root@hyp.local>, orig_to=<root>, relay=local, delay=0.02, delays=0.01/0/0/0.01, dsn=4.3.0, status=deferred (alias database unavailable)
Apr 11 21:00:01 hyp CRON[4140010]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Apr 11 21:00:01 hyp CRON[4140011]: (root) CMD (/backup.sh)
Apr 11 21:00:01 hyp CRON[4140010]: pam_unix(cron:session): session closed for user root
Apr 11 21:00:01 hyp postfix/pickup[4137050]: 0C737140FEB: uid=0 from=<root>
Apr 11 21:00:01 hyp postfix/cleanup[4140015]: 0C737140FEB: message-id=<@hyp.local>
Apr 11 21:00:01 hyp postfix/qmgr[894]: 0C737140FEB: from=<root@hyp.local>, size=586, nrcpt=1 (queue active)
Apr 11 21:00:01 hyp postfix/local[4140017]: error: open database /etc/aliases.db: No such file or directory
Apr 11 21:00:01 hyp postfix/local[4140017]: warning: hash:/etc/aliases is unavailable. open database /etc/aliases.db: No such file or directory
Apr 11 21:00:01 hyp postfix/local[4140017]: warning: hash:/etc/aliases: lookup of 'root' failed
Apr 11 21:00:01 hyp postfix/local[4140017]: 0C737140FEB: to=<root@hyp.local>, orig_to=<root>, relay=local, delay=0.02, delays=0.01/0/0/0.01, dsn=4.3.0, status=deferred (alias database unavailable)