• 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 Specific Scheduled Task (cronjob) isn't working

cmartinez127

Basic Pleskian
Server operating system version
CentOS 7
Plesk version and microupdate number
18.0.58 #2
We are having a problem with a specific Scheduled Task in Plesk. It's strange, because it works for a while and then fails for a while. And it works perfectly when run manually.
The task runs daily at 06:00, it's run by the subscription user (not root), it's a "Fetch an URL" task type and it adds images to products without images in a Prestashop website.

Here is a sample from "/var/log/cron" that shows the task ran automatically at 06:00 with no error message, but apparently it doesn't do anything (or at least we haven't found anything):
1708604481334.png

This is what we tried so far:
  • We changed "/bin/sh" to "/bin/bash" in this task, but didn't do anything.
  • We changed type of task from "Fetch an URL" to "Execute a command", we don't know if it was a coincidence, but it worked for a while. Unfortunately after a while it started to fail again.
  • We changed the user who runs the task, instead of the subscription user (####.es_z0ayymr3l1k) we tried with root. The logs shows no error messages but didn't do anything.1708604594651.png
  • We created exactly the same scheduled task/cronjob in a different server (the server was completely empty, only had this task) and it works perfectly, but that's not a solution, we need to make it work in the server where it belongs.

Today we got this message from the "Send a notification" option:
1708603746940.png

The error message made us think made us think about problems when running multiple cronjobs at the same time (this shouldn't be a problem, the server should be able to manage multiple tasks simultaneously), so we changed the original running time (06:00) to a new one (08:05), we chose 08:05 simply because there aren't tasks running at that time. I will update tomorrow about what happens after this change.

NOTE: We don't know if this has something to do with the issue or not, but at 06:00 one of the tasks that run simultaneously with the specific one it's the web crawler, which cache the entire web.

This is the task we are running tomorrow at 08:05, we created a log to save in it the output.
1708604737898.png

We don't know what are we missing, or what else to try or to do, if any of you could help us it would be great.
I think I provided almost everything that could be useful, if I can provide any other information about this, just let me know.
 
I understand the frustrating situation you're facing with your inconsistent scheduled task in Plesk. Here are some suggestions to help you resolve the issue:

1. Log Analysis:

  • Check detailed logs: While the "/var/log/cron" log shows no explicit errors, there might be more detailed information in other logs related to the task execution. Check your Plesk logs (e.g., psa logs, subscription logs) and the web server logs (e.g., Apache access logs, PHP error logs) for any relevant messages around the scheduled task execution time.
  • Focus on timeframes: Analyze the logs specifically around the times the task fails. Look for any errors, warnings, or unusual activity around those times.
2. Permissions and Ownership:
  • Directory permissions: Verify that the script has read and write permissions to the directories and files it needs to access (e.g., PrestaShop folders, image storage location).
3. Resource Limitations:
  • Check resource usage: Monitor CPU, memory, and disk usage during the scheduled task execution. If they reach peak levels, it might cause the task to fail. Consider optimizing the script or upgrading your hosting plan if necessary.
4. Debugging and Testing:
  • Manual execution with logging: Run the script manually at the scheduled time with additional logging enabled to capture the detailed output and identify any potential issues outside the Plesk environment.
  • Test on a different server: While your test on a different server didn't provide a permanent solution, it might offer clues. Compare the environment configurations and logs between the two servers to see if any differences point toward the problem.
Keep in mind, that fixing problems might take time. Look at the logs, try different things, and write down what you do to figure out what's wrong. If you keep trying and pay attention, you'll find and fix the issue with your scheduled task.
 
I understand the frustrating situation you're facing with your inconsistent scheduled task in Plesk. Here are some suggestions to help you resolve the issue:

1. Log Analysis:
  • Check detailed logs: While the "/var/log/cron" log shows no explicit errors, there might be more detailed information in other logs related to the task execution. Check your Plesk logs (e.g., psa logs, subscription logs) and the web server logs (e.g., Apache access logs, PHP error logs) for any relevant messages around the scheduled task execution time.
  • Focus on timeframes: Analyze the logs specifically around the times the task fails. Look for any errors, warnings, or unusual activity around those times.
2. Permissions and Ownership:
  • Directory permissions: Verify that the script has read and write permissions to the directories and files it needs to access (e.g., PrestaShop folders, image storage location).
3. Resource Limitations:
  • Check resource usage: Monitor CPU, memory, and disk usage during the scheduled task execution. If they reach peak levels, it might cause the task to fail. Consider optimizing the script or upgrading your hosting plan if necessary.
4. Debugging and Testing:
  • Manual execution with logging: Run the script manually at the scheduled time with additional logging enabled to capture the detailed output and identify any potential issues outside the Plesk environment.
  • Test on a different server: While your test on a different server didn't provide a permanent solution, it might offer clues. Compare the environment configurations and logs between the two servers to see if any differences point toward the problem.
Keep in mind, that fixing problems might take time. Look at the logs, try different things, and write down what you do to figure out what's wrong. If you keep trying and pay attention, you'll find and fix the issue with your scheduled task.
Yesterday we set the task to run as root instead of the subscription user and it worked. We hope that was the definitive solution.

1. We didn't find much useful information in other logs than "/var/log/cron". We found this log "/var/log/plesk/task-manager.log" which shows all tasks run, but we don't know how to identify our task because it has a format like this to identify them "task=5558 process=5558".

2. This cronjob it's actually not a script, it executes this plesk command "/usr/local/psa/admin/sbin/fetch_url" with an URL. Anyways I logged as root and the subscription user and ran this command manually and it works in both users.

3. That I remember the server never had major complaints about CPU, RAM or disk usage, anyways we will monitor it in the following task runs.

4. We already tested the task manually and it works fine, it just fails when is run automatically. We enabled logging for today's run and as I already confirmed, today's run worked so we got a 200 status code:
1708680737011.png
Unfortunately, testing in the other server it's not in my hands, we will see what can we do if it fails again.

Thanks,
Greetings.
 
Back
Top