Cron jobs and mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cron jobs and mail
# 1  
Old 09-18-2010
Cron jobs and mail

Hi,
I am new to this mail concept and cran jobs,i have given with a task to send a mail for every one hour from unix to my outlook by checking some sanitry checks kindly look the below queires and help me in this

1.)How to send a mail from unix box to outlook.

2.)I assigned to check a sanitry checks like
a.)Have to check large size file in approprite path
b.)IF it found a large size the file should have to compress.

3.)How to setup a cran jobs for sending a mail from unix to outlook for every one hour by executing all the above things.

4.)If we can able to do above things please conform that we can able to send mail with attachment from unix to oulook.

Pleas help on this.Smilie

Thanks in advance.Smilie

Regards
Thelak Kumar

Last edited by thelakbe; 09-18-2010 at 12:51 AM..
# 2  
Old 09-18-2010
There are several ways to send mail but probably the easiest way is to use mail/mailx depending on your system.

simple example
Code:
echo "message from UNIX here"|mailx -s "your subject here" user@exchange.domain.com

This User Gave Thanks to frank_rizzo For This Post:
# 3  
Old 09-18-2010
thanks for your support.

Please provide details about how to setup a cran job?
# 4  
Old 09-18-2010
Hi Thelak,

Look, first of all, we're talking about "cron" jobs, alright ! ...

Look, the tasks that you need to perform could be done inside a script, so you prepare a script with the tasks that you want and just set up the cron to execute them every hour, in this case .

1- Access your crontab with the following command
# crontab -e
(it is an empty file, you have to edit here what you need, the editor could be "vi")

2- Then add the following line.

0 * * * * /{path to your script}

---The 0 * * * * represents hourly, so the script will be processed every hour.

NOW, regarding the other points, look.

1- the mail!!!, use mailx ... I will show you how to do it soon
2- use find to "find" the large files, first, you have to define what is large for you.

eg. Find files greater then 5 megs (in bytes)

# find / -size +5000000c -exec ls -ltr {} \; --> this will show you the files, you have to refine this part to make it work with the file sizes that you really want.

OK... I will try to recreate what you are looking for.


Find the large files and compress them, let's say, files greater than 1GB ---- be carefull with this, you don't want to this with the OS files, etc.

Code:
find /tmp/files_to_shrink -size +1000000000c > /tmp/list_of_files

--- to see them
you can send this file to your email like this.

Code:
/tmp/list_of_files | mailx -s "files to compress" email@domain.com

If the file is ok, you can run a little script to read all that file, line per line, compress the files, then remove the files.

Hope that helps,

Marco,
This User Gave Thanks to ocramas For This Post:
# 5  
Old 09-18-2010
thanks alot for your great support i will try this.Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron Jobs

How to see which cron jobs are not running? (2 Replies)
Discussion started by: rahul.raj1989
2 Replies

2. Solaris

Cron jobs and at jobs

There are two jobs in Solaris , Cron and at jobs.. I know how to disable or enable cron jobs. How can I enable at jobs and disable it. Kindly help. Rj (2 Replies)
Discussion started by: jegaraman
2 Replies

3. Shell Programming and Scripting

cron jobs

Hi, please help on this am trying to exec the below mentioned cron jobs but its getting failed fro the past two days ###but when am trying to execte the cron by the times 23,29 18 * * * /export/home/inrvgo/thelak/China.sh its getting exec properly please help on this #... (8 Replies)
Discussion started by: thelakbe
8 Replies

4. Shell Programming and Scripting

Help with cron jobs

Hi Frenz, How do we get a cron job running in background to foreground ? (3 Replies)
Discussion started by: mkalase
3 Replies

5. Solaris

cron jobs

how to Put a cron entry which should be same script triggered on every Saturday and 1st of every month at 01.00 GMT. 0 2 1 * 6 --( At 2.00 GMT every sat & on 1st of every month) the above syntax is correct? Thanks (1 Reply)
Discussion started by: kurva
1 Replies

6. Solaris

Cron Jobs

I'm trying to run cron jobs to start any inhibited processes after a system reboot. I can schedule th cron, but i'm confused as to how to incorporated the reboot, since reboot is scheduled at different times, once every month. How can I write this to start every 15 min after after a reboot ... (2 Replies)
Discussion started by: Remi
2 Replies

7. UNIX for Advanced & Expert Users

cron jobs

I need to monitor my cron jobs with another unix machine since occasionally the cron will go down on the main server but there are no errors. Can anyone help with a script to write to use the cron on the back up machine to monitor the main server? I am using SCO and the cron jobs have been... (3 Replies)
Discussion started by: rmarral
3 Replies

8. UNIX for Dummies Questions & Answers

Cron Jobs

Where can someone find info on Cron Jobs? Very new to UNIX and the PC I inherited looks to have several of them. Looks like they are some kind of background program that runs automatically at specified times. Would like to delete some of them and know more about them. (6 Replies)
Discussion started by: dereckbc
6 Replies

9. UNIX for Dummies Questions & Answers

cron jobs

I was wondering if itīs possible to cron job not to run on a certian day and time. Iīve got a job that runs everyday at 08:00 but would like it not to run on the 20:th between 08:00 and 10:00 Anyone know if this is possible, and if. How do i do it? regards... dOzY (3 Replies)
Discussion started by: dozy
3 Replies

10. Shell Programming and Scripting

cron jobs

hi folks, I need an explanation on cron jobs with an example (4 Replies)
Discussion started by: vijaysabari
4 Replies
Login or Register to Ask a Question