Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.

Cron job scheduled is running once, but reports are generating twice

Login or Register to Reply

Thread Tools Search this Thread
# 1  
Cron job scheduled is running once, but reports are generating twice


Hope you all are doing fine

I have one admin server which is being used dedicately to run cron jobs on hourly basis, fetching the details from Database which is in a different server.These cronjob are run on every hourly/5 minutes basis depending as per end user requirement.The script are based on admin server itself where the cron is enabled
The cron jobs are basically reports which end users need for their records

OS version is Red Hat Enterprise Linux Server release 6.6 where the cronjob is set

Now the tricky point:
1)Since last week, everything was getting run once, but when we query the database we are seeing duplicate entries for each cronjobs and the reports are published twice

2) Also, even when I have disabled/removed/changed the timestamp from crontab, we still see the duplicate entries on the database.

Need to find out why this is happening and its remedy,Can anyone guide please.

# 2  
You might consider to add a few lines of code to your crontab scripts to write to a log file and record each time the cron file runs.

You might consider creating a new database table which records each time the database is queried by the cron file script and add login information and time stamps to the (new) db table, if one does not exist.

Basically, I am suggesting that if you have better logging in place, you can easily discover how things are running as they are.
# 3  
Thanks Neo,

But i am trying to do things in the existing setup, the cron was working fine without any duplicate.
Also, I do have restrictions on creating/modifying the DB as its running live environment
# 4  
You say,
Cron job scheduled is running once
in your thread title but how can you be so sure that it's only running once?

IMHO the most likely thing is that it's being spawned (by cron) more than once for some reason.

So what are the possible reasons?

1. There is more that one crontab entry for this same job either both with the same user or once each with different users. To check look for your cron tables in /var/spool/cron (or possibly /var/spool/cron/crontabs). In there you will find one file for each and every user that has cron jobs scheduled. You can list these to see the contents using cat. Look in all the user files for this job entry; as I said, one could be running, for example, as root, and a second as some other user. Do not edit these files directly without coming back for advice first. However, you should be able to use normal cron tools to remove any excess entry that you find.

2. Perhaps, somehow, you have more than one cron daemon running. When the system boots it should start just one daemon. To check look for the cron daemon(s) in the ps -eaf listing.
# 5  
Thank you Hick,

I have cross check it, daemon are running only once & also apart from the [/var/spool/cron/user1] I dont see any other user apart from user1 who has enabled the jobs running.. I confirm there is no duplicates.
# 6  
So check the cron script itself to ensure that some editing session hasn't put in duplicate lines.
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Scheduled job not running automatically in crontab
Santhosh CJ
i have a job scheduled in crontab. The problem is, it is not running automatically as per the time scheduled. But runs when executed manually. What would be the problem? Help me with this please.... Shell Programming and Scripting
Shell Programming and Scripting
Cron Jobs not running at scheduled time
I've scheduled few jobs using cron. But they are not running ..... What might be the possible reasons ?? Also tell me how to troubleshoot............. Please help me ....... Thanks in Advance.... Red Hat
Red Hat
Oracle Scheduled job not running as per schedule.
Hi, Though this is a unix forum mainly, am posting this oracle query here hoping to get a resolution. I have set up two scheduled jobs in oracle 11g for executiong a procedure in specific time intervals. One as Hourly and other as minutely. But the scheduled jobs are not running as per...... Programming
problem when the script is scheduled to run as cron job
Hello, I have problem in executing a shell script. When the shell script is executed at the shell prompt the script works successfully but when the same script is run as a cron job it fails to execute the files called within the shell script. I have scheduled the job in my crontab file as ...... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers
Conditional File Movement script scheduled using CRON job
Hi All, i am trying to automate a process and have to create a unix script like wise. I have a scenario in which i need to automate a file movement. Below are the steps i need to automate. 1. Check whether a file (Not Fixed name-Pattern search of file say 'E*.dat') is present in a...... Shell Programming and Scripting
Shell Programming and Scripting

Featured Tech Videos