-1

I have set my cron job to be executed every 15 minutes. my cron job is */15 * * * * /usr/bin/python3.6 /home/ubuntu/main.py >> /tmp/file

Above job will execute every 15 minutes and send the emails. But I receive two emails at one time. so I checked the logs. I found that It was executed twice at a time. in the logs, you could see the highlighted one executed at 05:17 but there was a job earlier executed at 05:15 the time gap is 2 minutes. but the time gap I set was 15 minutes. so Could I get the reason behind it?

Oct  1 23:15:51 escnn CRON[10086]: (CRON) info (No MTA installed, discarding output)
Oct  1 23:17:01 escnn CRON[10164]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  1 23:30:01 escnn CRON[10240]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  1 23:30:54 escnn CRON[10239]: (CRON) info (No MTA installed, discarding output)
Oct  1 23:45:01 escnn CRON[10318]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  1 23:45:54 escnn CRON[10317]: (CRON) info (No MTA installed, discarding output)
Oct  2 00:00:01 escnn CRON[10396]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 00:00:54 escnn CRON[10395]: (CRON) info (No MTA installed, discarding output)
Oct  2 00:15:01 escnn CRON[10474]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 00:15:53 escnn CRON[10473]: (CRON) info (No MTA installed, discarding output)
Oct  2 00:17:01 escnn CRON[10552]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  2 00:30:01 escnn CRON[10556]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 00:31:06 escnn CRON[10555]: (CRON) info (No MTA installed, discarding output)
Oct  2 00:45:02 escnn CRON[10634]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 00:46:03 escnn CRON[10633]: (CRON) info (No MTA installed, discarding output)
Oct  2 01:00:01 escnn CRON[10702]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 01:00:55 escnn CRON[10701]: (CRON) info (No MTA installed, discarding output)
Oct  2 01:15:01 escnn CRON[10781]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 01:15:55 escnn CRON[10780]: (CRON) info (No MTA installed, discarding output)
Oct  2 01:17:01 escnn CRON[10858]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  2 01:30:01 escnn CRON[10862]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 01:31:08 escnn CRON[10861]: (CRON) info (No MTA installed, discarding output)
Oct  2 01:45:01 escnn CRON[10944]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 01:46:03 escnn CRON[10943]: (CRON) info (No MTA installed, discarding output)
Oct  2 02:00:01 escnn CRON[11022]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 02:00:51 escnn CRON[11021]: (CRON) info (No MTA installed, discarding output)
Oct  2 02:15:01 escnn CRON[11101]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 02:16:11 escnn CRON[11100]: (CRON) info (No MTA installed, discarding output)
Oct  2 02:17:01 escnn CRON[11179]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  2 02:30:01 escnn CRON[11183]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 02:31:07 escnn CRON[11182]: (CRON) info (No MTA installed, discarding output)
Oct  2 02:45:01 escnn CRON[11262]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 02:45:56 escnn CRON[11261]: (CRON) info (No MTA installed, discarding output)
Oct  2 03:00:01 escnn CRON[11341]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 03:00:56 escnn CRON[11340]: (CRON) info (No MTA installed, discarding output)
Oct  2 03:15:01 escnn CRON[11419]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 03:15:51 escnn CRON[11418]: (CRON) info (No MTA installed, discarding output)
Oct  2 03:17:01 escnn CRON[11485]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  2 03:30:01 escnn CRON[11489]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 03:30:54 escnn CRON[11488]: (CRON) info (No MTA installed, discarding output)
Oct  2 03:45:01 escnn CRON[11567]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 03:45:52 escnn CRON[11566]: (CRON) info (No MTA installed, discarding output)
Oct  2 04:00:01 escnn CRON[11645]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 04:01:12 escnn CRON[11644]: (CRON) info (No MTA installed, discarding output)
Oct  2 04:15:01 escnn CRON[11723]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 04:16:13 escnn CRON[11722]: (CRON) info (No MTA installed, discarding output)
Oct  2 04:17:01 escnn CRON[11801]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  2 04:30:01 escnn CRON[11805]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 04:32:04 escnn CRON[11804]: (CRON) info (No MTA installed, discarding output)
Oct  2 04:45:01 escnn CRON[11883]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 04:46:11 escnn CRON[11882]: (CRON) info (No MTA installed, discarding output)
Oct  2 05:00:01 escnn CRON[11961]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 05:01:00 escnn CRON[11960]: (CRON) info (No MTA installed, discarding output)
Oct  2 05:15:01 escnn CRON[12159]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 05:17:01 escnn CRON[12225]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  2 05:17:27 escnn CRON[12158]: (CRON) info (No MTA installed, discarding output)
Oct  2 05:30:01 escnn CRON[12240]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 05:31:05 escnn CRON[12239]: (CRON) info (No MTA installed, discarding output)

enter image description here

Sathiyakugan
  • 674
  • 7
  • 20
  • Does the log show a problem as described? I can't see it. Voting to close as unclear what you are asking – Vorsprung Oct 02 '18 at 05:49
  • @Vorsprung now check it. sorry for the inconveniences. – Sathiyakugan Oct 02 '18 at 05:59
  • The selected entry pretty clearly isn't the same job running again. You should review and/or post the contents of your script, because that's more likely to be the source of the duplicate emails; cron itself is not exactly an unstable package (unless it's been subject to some kind of user configuration abuse). Also, please do not use screenshots; they're unsearchable and uncopyable. – kungphu Oct 02 '18 at 06:02
  • @kungphu updated. I have executed crontab -e to check what are the script in the job . I see only the above task. but here "cd / && run-parts --report /etc/cron.hourly" This is not in my code – Sathiyakugan Oct 02 '18 at 06:06
  • No, it wouldn't be in your code or your crontab; that's a [system task](https://askubuntu.com/questions/635704/strange-root-cronjob-ive-never-set-it). I'm not suggesting your crontab is the issue, I'm suggesting your code itself (`main.py`) is being executed once but sending its email twice. – kungphu Oct 02 '18 at 06:10

1 Answers1

0
Oct  2 05:00:01 escnn CRON[11961]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 05:01:00 escnn CRON[11960]: (CRON) info (No MTA installed, discarding output)
Oct  2 05:15:01 escnn CRON[12159]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 05:17:01 escnn CRON[12225]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct  2 05:17:27 escnn CRON[12158]: (CRON) info (No MTA installed, discarding output)
Oct  2 05:30:01 escnn CRON[12240]: (ubuntu) CMD (/usr/bin/python3.6 /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py  >> /tmp/file)
Oct  2 05:31:05 escnn CRON[12239]: (CRON) info (No MTA installed, discarding output)

This log extract does not show the /home/ubuntu/Deploy/LSTM_Attention_IMDB_New_open.py script running twice at 5:15

The event at 5:17 is root cron hourly

Hope this helps

Vorsprung
  • 32,923
  • 5
  • 39
  • 63