LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2012, 06:43 PM   #1
Sharkadder
LQ Newbie
 
Registered: Dec 2012
Posts: 12

Rep: Reputation: Disabled
Introduction and question about Cron and e-mail


Hi there,

I have been using Linux systems for a number of years and have delt in many platforms including Ubuntu, Kubuntu ontop of that, Fedora and also some private based images.

Basically what it is yeah, i have some web hosting on a linux based Apache web server and have only recently started to look into using the crontab commands again (it has been a while since me using it when programming in Python).

The question i have is, i can set a cron off every hour and i will receive an e-mail about what has been executed etc. but what i wanted to know is, can i make the e-mail only be sent at midnight on the day? So the script runs 24 times in the day but i only get e-mailed from the Cron which runs at midnight.

The reason is, the web space that i rent only allows me to do one cron job and i am trying to find a way to execute it every hour but only send the e-mail for something once per day. Any solutions are great.

The Cron will be executing a cron.php file where part of this file will only execute at a certain time. I am familiar with PHP and the time functions if you think i could maybe do something with them to only send the e-mail out once a day. Just i am unsure how i can create a link in the cron.php file to e-mail out everything which is executed only at midnight.

Any suggestions are welcome...quite a puzzling question i thought for a first post from a new member lol. If this is in the wrong forum then can somebody move it please to the right section and any help is much appreciated as when doing a search on the net i have found nothing to help me with this.

Last edited by Sharkadder; 12-11-2012 at 06:47 PM.
 
Old 12-12-2012, 01:46 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Quote:
the web space that i rent only allows me to do one cron job
per day ?? Seriously???
Personally I'd go elsewhere; that's ridiculous.

However, IF(!) I had to live with it I'd write a daemon to do the data gathering hourly and run the cron job once a day to send the email.
(Actually, rather than waste the cron job, I'd get the daemon to do the email as well)

Last edited by chrism01; 12-12-2012 at 06:30 PM. Reason: typo
 
Old 12-12-2012, 11:23 AM   #3
Sharkadder
LQ Newbie
 
Registered: Dec 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi Chris,

I shall look into this, the cron i have can be executed multiple times per day but i only have access to the one cron job. i.e. multiple sends but i cannot figure a way to do the cron every hour but only send the e-mail which comes with it once per day. Do you know how i can maybe resolve this? Don't think my shared hosting has access to a Daemon which is a shame, restricted access and all that etc. :-(.

Many thanks,

Mark

Last edited by Sharkadder; 12-12-2012 at 11:25 AM.
 
Old 12-12-2012, 11:49 AM   #4
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
You could run a script that has different behaviour depending on factors like:
is it midnight (within a small interval)?
have I already got 23 stored outputs from previous runs?
 
Old 12-12-2012, 01:03 PM   #5
Sharkadder
LQ Newbie
 
Registered: Dec 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi ans thanks for the reply,

I could do your suggestion but when you do a cron command the e-mail runs from the actual command and not through any form of PHP script. That why i wondered if there was any specific parameter attached to cron.

My con job currently looks like this to let it e-mail once every day but don't know a command to make it go off every hour and only e-mail once per day:

0 1 * * * TERM="xterm"; /usr/bin/lynx -dump http://mysite.com/mycronpage.php

Many thanks :-) and let me know what you think i can do or if i am at my limit just doing it all from one command,

Mark
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: A Short Introduction To Cron Jobs LXer Syndicated Linux News 0 04-08-2009 04:40 PM
Cron mail sending using outside SMTP mail server Utah Linux - Software 6 08-24-2005 08:44 PM
No More Cron Mail, Cron Error? Xhost Linux - General 3 07-26-2004 05:28 PM
need only cron job mail on my mail id manojthakkar Linux - Newbie 0 12-20-2003 06:41 AM
Cron: E-Mail me only when necessary elconde Linux - General 3 05-31-2002 10:40 AM


All times are GMT -5. The time now is 06:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration