• 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

Resolved My cron jobs runs twice

VojinP

Basic Pleskian
Server operating system version
CentOS Stream 8
Plesk version and microupdate number
Plesk Obsidian v18.0.41
I had setup scheduled tasks to run (fetching url), some of them were to send emails to certain people marked in email cron table. But we have noticed they all receive email twice? I was looking for mistake in code but code was correct. However, I have put in cron srcipt to record in txt file when they were run and I have noticed many of them runs twice.
Problem begins when I have noticed awhile that all cron job tasks are marked as disabled, but they were actually running. I just marked them enabled, but now they are running twice. I don't want to mark them back disabled. Any idea how to fix the issue?
Note that I have added a new cron job after enabling all previous and that job is running only once as expected.
 
Are those cron jobs you've setup as administrator/root user? Or as a domain user in Plesk for specific domains?

If connect to your server using SSH and run crontab -l, does the outputted list match the cron jobs listed in Plesk?
 
Are those cron jobs you've setup as administrator/root user? Or as a domain user in Plesk for specific domains?

If connect to your server using SSH and run crontab -l, does the outputted list match the cron jobs listed in Plesk?
I have added them as a user for specific domain. When I check
Code:
crontab -l
, there are no jobs listed. When I type
Code:
crontab -l -u <username>
I got them listed, all, just once (as expected).
 
here is the output for crontab -l -u:

Code:
[root@thebox ~]# crontab -l -u domain.com
MAILTO="[email protected]"
SHELL="/bin/sh"
# 0,15,30,45      * * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/stats')  > /dev/null
MAILTO="[email protected]"
SHELL="/bin/sh"
# 4,9,14,19,24,29,34,39,44,49,54,59 * * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/report')  > /dev/null
MAILTO="[email protected]"
SHELL="/bin/sh"
# 2,7,12,17,22,27,32,37,42,47,52,57 * * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/mail')  > /dev/null
0 3 * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/tmp')  > /dev/null
0 8 * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/ccchaser1')  > /dev/null
5 8 * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/ccinvitefollowup')  > /dev/null
10      8 * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/ccchaserfollowup')  > /dev/null
MAILTO=""
17,47   * * * * /opt/plesk/php/7.4/bin/php -f 'httpdocs/wp-cron.php'
MAILTO="[email protected]"
3,8,13,18,23,28,33,38,43,48,53,58 * * * * (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/dpreport')  > /dev/null

first three jobs (most essential) are actually disabled but they are still running... very weird. If enabled, they run twice.
 
I have checked if (somehow) crond process is runnign twice... nope.
Code:
[root@thebox ~]# ps aux | grep crond
root     2407982  0.0  0.0  37128  3896 ?        Ss   May05   0:07 /usr/sbin/crond -n
[root@thebox ~]#
 
I came across this Stackoverflow post with a similar issue, which has some useful suggestions. Why is this cron entry executed twice? Maybe this helps you narrow it down?
Unfortunately it does not help. I have already checked is cron running twice, nope.
Code:
[root@thebox ~]# ps -A | grep crond
2407982 ?        00:00:07 crond
[root@thebox ~]# whoami

what is confusing is that I have listed cron logs, there are no logs of cron jobs disabled in plesk panel, like they are not running, but in fact they are running. There is only one job I have added later to account which is working as expected and logging as expected.
 
This is becoming a twilight zone. I have added
PHP:
sleep(10);
command to extend execution of cron scripts so I can "catch" them with some commands. When cron which is regularly working (/dpreport) is running, I caught it with
Bash:
 ps axjf
command, and it looks like this:

Code:
      1 2407982 2407982 2407982 ?             -1 Ss       0   0:07 /usr/sbin/crond -n
2407982 2747326 2407982 2407982 ?             -1 S        0   0:00  \_ /usr/sbin/CROND -n
2747326 2747328 2747328 2747328 ?             -1 Ss   10000   0:00      \_ /bin/sh -c (/usr/local/psa/admin/sbin/fetch_url 'https://my.domain.com/cron/dpreport')  > /dev/null
2747328 2747329 2747328 2747328 ?             -1 S    10000   0:00          \_ /bin/bash /usr/local/psa/admin/sbin/fetch_url https://my.domain.com/cron/dpreport
2747329 2747331 2747328 2747328 ?             -1 S    10000   0:00              \_ /usr/bin/curl -A Plesk (fetch_url utility) -sS -L -k -o /tmp/tmp.9cMY7w7oKA -w %{http_code} https://my.domain.com.com/cron/dpreport

when I wanted to see other cronjobs that are disabled but still running - there were no processes running and under cron task there was nothing. Looks like some other process is doing the job. I have waiting on
Bash:
top
command to see what happens when cronjobs are running, nothing was suspicious... And crons are running for sure since I log to txt file time and cron name running.
 
I am SO SORRY for bothering you guys... just figure out an issue. Our website was first on test server which is not dead yet and it is working as well as cronjobs on it. Since I'm not calling php scripts but rather fetching url, and on old server there is no more my subdomain, it was calling tasks on new server :)
Once again, I'm SORRY. Thanks for understanding.
 
Back
Top