LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 05-28-2004, 05:39 AM   #1
macaldwell
LQ Newbie
 
Registered: May 2004
Location: Cincinnati
Posts: 9

Rep: Reputation: 0
Talking How to schedule an automated job


Hi All,

I am kind of new to this. I am running Fedora Core 1 and would like to run a cron job to email me my IP address every so often since I am using DHCP and want to log into my machine remotely. I am not sure what a script like this would look like. Can someone please help me?

Thanks
 
Old 05-28-2004, 05:59 AM   #2
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
You can do something like:
Code:
/sbin/ifconfig | sendmail email@address
but IMO there's a better alternative, go to http://www.afraid.org and use their dynamic DNS service(its free), even if you don't have your own domain they allow you to use subdomains from a list of public domains, and they have scripts you can run periodly to refresh your ip address.
 
Old 05-28-2004, 11:07 AM   #3
macaldwell
LQ Newbie
 
Registered: May 2004
Location: Cincinnati
Posts: 9

Original Poster
Rep: Reputation: 0
Didn't work here are the results of the command you gave

Hi all here is what happend when I tried that, I just recently upgraded to Fedora Core 2.

[root@localhost mcaldwell]# /sbin/ifconfig | sendmail macaldwell@cinci.rr.com
bash: sendmail: command not found
[root@localhost mcaldwell]#


Any other suggestions? I use dyndns.org for a free domain and not sure if they have scripts you can setup or not

Thanks for your help
 
Old 05-28-2004, 11:26 AM   #4
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
try use absolution path to the commands
like /usr/sbin/sendmail or wherever it is
 
Old 05-28-2004, 11:58 AM   #5
Pete M
Member
 
Registered: Aug 2003
Location: UK
Distribution: Redhat 9 FC 3 SUSE 9.2 SUSE 9.3 Gentoo 2005.0 Debian Sid
Posts: 657

Rep: Reputation: 32
macaldwell

Try this, sustitute ? with your own setting

/sbin/ifconfig eth? | grep 'inet addr:'| mail macaldwell@cinci.rr.com

Pete
 
Old 05-28-2004, 05:54 PM   #6
macaldwell
LQ Newbie
 
Registered: May 2004
Location: Cincinnati
Posts: 9

Original Poster
Rep: Reputation: 0
Hey Pete and everyone else,

When I did what you had suggested it said something to the fact of no message no subject hope thats ok. Does this make sense? And my other question is this supposed to go in the cron job? or run this in shell?

Thanks for the help
 
Old 05-28-2004, 06:34 PM   #7
Pete M
Member
 
Registered: Aug 2003
Location: UK
Distribution: Redhat 9 FC 3 SUSE 9.2 SUSE 9.3 Gentoo 2005.0 Debian Sid
Posts: 657

Rep: Reputation: 32
macaldwell

Just tried it again 3 times using different email addresses, one to my hotmail account and it works everytime

Try a simple version

Code:
/sbin/ifconfig | mail macaldwell@cinci.rr.com
Pete
 
Old 05-29-2004, 08:02 AM   #8
macaldwell
LQ Newbie
 
Registered: May 2004
Location: Cincinnati
Posts: 9

Original Poster
Rep: Reputation: 0
Pete,

I got a question, I did get this to work and sent it to my yahoo address. My question is is there something I can add to the script that will automatically do that say every 2 hours or so?
 
Old 05-29-2004, 02:07 PM   #9
Pete M
Member
 
Registered: Aug 2003
Location: UK
Distribution: Redhat 9 FC 3 SUSE 9.2 SUSE 9.3 Gentoo 2005.0 Debian Sid
Posts: 657

Rep: Reputation: 32
macaldwell

You can set it as a cron job, are you familiar with VI it's a text editor ?

Anyway here goes

Code:
$ crontab -e
This should open a text editor showing a list of cron jobs or a blank page if you don't have any existing jobs

Enter the following text

0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /sbin/ifconfig | mail macaldwell@cinci.rr.com

Save the file and you should get a confirmation
crontab: installing new crontab



Pete

Last edited by Pete M; 05-29-2004 at 03:05 PM.
 
  


Reply



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
how to schedule an "at" job to start when another finishes? ashlock Programming 10 01-13-2005 11:12 PM
Is core 2 on schedule? Rotwang Fedora 2 05-10-2004 05:08 PM
schedule job to be run at 8:00pm every night ashley75 Linux - General 22 10-24-2003 12:44 PM
Schedule, AGAIN!! erathomor Linux - General 0 04-11-2002 11:25 AM
HOW TO Schedule erathomor Linux - General 3 04-10-2002 01:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:17 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
Open Source Consulting | Domain Registration