Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-25-2003, 08:06 AM
|
#1
|
Member
Registered: Oct 2003
Distribution: Debian
Posts: 57
Rep:
|
cron Email
How can I get a cron job that I have set up to email me the output of the commands that run?
|
|
|
10-25-2003, 08:58 AM
|
#2
|
Member
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532
Rep:
|
Try something like this:
----------------------------
#! /bin/sh
(
echo Running cron Job ....
ls -la
date
) 2>&1 | mail root
----------------------------
|
|
|
10-25-2003, 09:56 AM
|
#3
|
Member
Registered: Apr 2003
Location: Madrid
Distribution: RHEL, Kubuntu, Solaris, TRU64
Posts: 382
Rep:
|
Usually, all cron jobs route message to the local Inbox of the user running the job. I.e.: If you run your cron job as root, then root will get all mail messages.
You can check with "mail" command of course. BUT what you want I guess is to receive it in your @domain.com account, don't you ?
You have to use "aliases":
edit /etc/aliases
add your email to the "root" line (or to the user under which you run your cron jobs). I.e.:
root name@yahoo.com
alfred name@yahoo.com
- Save the file and run "newaliases" command:
root@mymachine # newaliases
root@mymachine #
Now you are done.
|
|
|
10-26-2003, 04:49 AM
|
#4
|
Member
Registered: Oct 2003
Distribution: Debian
Posts: 57
Original Poster
Rep:
|
I thought it should email automatticly. It's not however.
All I did to set up the cronjob is create a script in the cron.daily directory. How can I tell which user account it runs under? I am a newbie!
I will try the first suggestion, as the second dos'nt really apply in this case.
|
|
|
10-26-2003, 04:53 AM
|
#5
|
Member
Registered: Oct 2003
Distribution: Debian
Posts: 57
Original Poster
Rep:
|
Sorry, it may help if I post the file contents!
Here is my cron job
#!/bin/sh
/usr/bin/sa-learn --spam --rebuild --mbox /var/spool/mail/salearn
Is that correct?
|
|
|
10-26-2003, 07:16 AM
|
#6
|
Member
Registered: Apr 2003
Location: Madrid
Distribution: RHEL, Kubuntu, Solaris, TRU64
Posts: 382
Rep:
|
-First I'd try to check if your job is really executing.
-Then we'll check if it mails or not.
For the first, add "2>&1>/tmp/kk.log" to your command:
#!/bin/sh
/usr/bin/sa-learn --spam --rebuild --mbox /var/spool/mail/salearn 2>&1>/tmp/kk.log
If the job is executed, would create a file (kk.log) in /tmp directory with the results of the command. There you can look for explanations.
When the cron execution is confirmed, you'd step to the mail concern.
|
|
|
10-26-2003, 10:00 AM
|
#7
|
Member
Registered: Oct 2003
Distribution: Debian
Posts: 57
Original Poster
Rep:
|
I'll do that, but it has run, because it was set to delete a file, which it did, I later took that line out to correct a error.....
Lets see if kk.log is created!!!!
Thanks for the help, we'll get the mail working later!
Mike
|
|
|
All times are GMT -5. The time now is 09:38 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|