• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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