Visit The New, Modern Unix Linux Community


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


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Cron job scheduled is running once, but reports are generating twice
# 1  
Cron job scheduled is running once, but reports are generating twice

Team,

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.

Regards
Whizkid
# 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,
Quote:
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.
# 7  
Logging is your friend Smilie
This User Gave Thanks to Neo For This Post:

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #525
Difficulty: Medium
In ASCII, to convert between uppercase and lowercase versions, you only need to invert the second bit (0 for uppercase, 1 for lowercase).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Scheduled job not running automatically in crontab

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. (6 Replies)
Discussion started by: Santhosh CJ
6 Replies

2. Red Hat

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. (2 Replies)
Discussion started by: vamshigvk475
2 Replies

3. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

4. Solaris

Cron job is not running

Hi, I have set up the crontab as follows. root@IDC4VASAPP07 # crontab -l 0-59 * * * * /var/tmp/r.sh 0-59 * * * * date >> /var/tmp/log root@IDC4VASAPP07 # r.sh is as follows. root@IDC4VASAPP07 # cat r.sh #!/bin/bash dt1=$(perl -e 'use POSIX;print strftime... (10 Replies)
Discussion started by: SunilB2011
10 Replies

5. Programming

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... (2 Replies)
Discussion started by: suresh_kb211
2 Replies

6. UNIX for Dummies Questions & Answers

Cron job not running

Hi All, I am editing crontab using -e option to add a new job Below is the line 30 * * * * scriptpath This job is not executing every thirty minutes. I have checked, cron daemon is running. What did I miss? Can some one help? I am using cron shell..ksh (7 Replies)
Discussion started by: yabhi_22
7 Replies

7. UNIX for Dummies Questions & Answers

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 ... (6 Replies)
Discussion started by: forumthreads
6 Replies

8. HP-UX

Cron Job Not Running

Hi, I have a cron schedule like this 04,16,28,40,52 * * * * /nag/startProcessABatch (unix script) i want to add new lines in this file (like Logging), i just copy this file into a /tmp folder (for backup copy), and i have edited this file (added few lines of code for logging). ... (1 Reply)
Discussion started by: nag_sundaram
1 Replies

9. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: imu
2 Replies

10. Shell Programming and Scripting

How to implement cron job to run my reports dynamically?

How to implement cron job. Ex: I need to run SQR reports dynamically by using cron job. How can I implement cron job in shell.. If any one is having sample script in any shell that would be great help to me. Thanks Siva (1 Reply)
Discussion started by: siva
1 Replies

Featured Tech Videos