• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Scheduled Tasks: cron job (mysqldump) creates an empty file

John S.

New Pleskian
Cron job doesn't run properly, when testing it from Scheduled Tasks or running automatically on a schedule - creates a zero-length empty gzip file (running mysqldump)

This is how to replicate it:
  1. Create a cron job, e.g.
    mysqldump -h localhost -u rs_mst -ppasword rs_mst admin_custom performance-aum_custom | gzip > /etc/backups/daily/cust_funds/mst_`date -I`.gz
  2. Click Run Now (being on the same cron job page - not in the main Scheduled Tasks page)
  3. Everything runs perfectly, the gzip file is created.
  4. Click OK.
  5. Select that task on the Scheduled Tasks page and click Run Now (the button on the left, in the task table).
  6. It returns 'successfully completed', but the ceated gzip file is empty, has zero length.
  7. Adding a full path, i.e. /usr/bin/mysqldump makes no difference
  8. All folder permissions are 755, owner root:root.
I also tested setting chmod 777 on /etc/backups/daily/cust_funds, but it makes no difference. The task works only when runs from the Task Edit Page.

What am I doing wrong?

Thanks!
 
Last edited:
Cron job doesn't run properly, when testing it from Scheduled Tasks or running automatically on a schedule - creates a zero-length empty gzip file (running mysqldump)

This is how to replicate it:
  1. Create a cron job, e.g.
    mysqldump -h localhost -u rs_mst -ppasword rs_mst admin_custom performance-aum_custom | gzip > /etc/backups/daily/cust_funds/mst_`date -I`.gz
  2. Click Run Now (being on the same cron job page - not in the main Scheduled Tasks page)
  3. Everything runs perfectly, the gzip file is created.
  4. Click OK.
  5. Select that task on the Scheduled Tasks page and click Run Now (the button on the left, in the task table).
  6. It returns 'successfully completed', but the ceated gzip file is empty, has zero length.
  7. Adding a full path, i.e. /usr/bin/mysqldump makes no difference
  8. All folder permissions are 755, owner root:root.
I also tested setting chmod 777 on /etc/backups/daily/cust_funds, but it makes no difference. The task works only when runs from the Task Edit Page.

What am I doing wrong?

Thanks!

Hello,
Have you tried without gzip ?
And you can use the variable MYSQL_PWD to not display a password in cronjob :
Code:
MYSQL_PWD=$(cat /etc/psa/.psa.shadow) mysqldump -uadmin --single-transaction yourdatabase | gzip > /var/lib/backup-$(date +"%d-%m-%Y").gz
 
Is the job owner ("run task as ...") root in both cases?
Yes, it is root for all jobs. BTW, how can I change the job owner for a particular job? Are are any settings to change the job owner?

Also, the same cron script works perfectly fine for my other servers with very old Plesk panels (11.0.9 and 11.5).
 
Have you tried without gzip ?
And you can use the variable MYSQL_PWD to not display a password in cronjob :

Yes, I tried without gzip and also with the full path to gzip. The only way I can make it work is to use sh script instead of command line. I just wanted to understand what the problem with the new Scheduled Tasks module and why it cannot execute a command line mysqldump.

Thanks for the password tip.
 
Back
Top