Problem with crontab not executed...

cpulove

Member
Jul 12, 2024
44
4
8
I installed the following crintab, to backup my /pve/etc folder daily:

crontab -e

0 0 * * * tar czvf /pve-backup/pve-backup-$(date +%F).tar.gz /etc/pve/

Unfortunately the crontab does not execute. Instead the single command via ssh works just fine.

Any idea what could solve the problem?
Code:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
0 0 * * * tar czvf /pve-backup/pve-backup-$(date +%F).tar.gz /etc/pve/

systemctl status cron
Code:
● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; preset: enabled)
     Active: active (running) since Tue 2025-01-07 10:55:19 CET; 41min ago
       Docs: man:cron(8)
   Main PID: 1817000 (cron)
      Tasks: 1 (limit: 153458)
     Memory: 404.0K
        CPU: 275ms
     CGroup: /system.slice/cron.service
             └─1817000 /usr/sbin/cron -f

Jan 07 11:30:01 pve CRON[1871738]: (root) CMD (tar czvf /pve-backup/pve-backup-$(date +)
Jan 07 11:30:01 pve CRON[1871737]: pam_unix(cron:session): session closed for user root
Jan 07 11:31:01 pve CRON[1873319]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Jan 07 11:31:01 pve CRON[1873320]: (root) CMD (tar czvf /pve-backup/pve-backup-$(date +)
Jan 07 11:31:01 pve CRON[1873319]: pam_unix(cron:session): session closed for user root
Jan 07 11:32:01 pve CRON[1874858]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Jan 07 11:32:01 pve CRON[1874859]: (root) CMD (tar czvf /pve-backup/pve-backup-$(date +)
Jan 07 11:32:01 pve CRON[1874858]: pam_unix(cron:session): session closed for user root
Jan 07 11:33:01 pve cron[1817000]: (root) RELOAD (crontabs/root)
Jan 07 11:35:01 pve cron[1817000]: (root) RELOAD (crontabs/root)
Jan 07 11:35:01 pve cron[1817000]: (root) RELOAD (crontabs/root)
 
For cmd "date" also.
And in linux there are these divers cron dir's in /etc/cron* which are the newer way to do that instead of the old unix style in /var/spool/cron by "crontab -e".
 
  • Like
Reactions: cpulove
For cmd "date" also.
And in linux there are these divers cron dir's in /etc/cron* which are the newer way to do that instead of the old unix style in /var/spool/cron by "crontab -e".

Indeed it was the "date"...
thx, figured it out now

this

0 0 * * * tar czvf /pve-backup/pve-backup_$(date +\%Y-\%m-\%d).tar.gz /etc/pve/

works!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!