• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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