LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices

Reply
 
Search this Thread
Old 02-09-2011, 06:57 PM   #1
ncn8ochaser
LQ Newbie
 
Registered: Nov 2010
Posts: 5

Rep: Reputation: 0
Talking Solving problems on your own is VERY rewarding!!


I'm going to make this rather quick but I just want to say this...

Code:
#!/bin/bash

sudo top -b -n 1 > /home/admin/stats.txt

sudo sendEmail -v -f admin@server.com -s smtp.gmail.com:587 -xu myusername -xp mypasswd -t myemail@gmail.com -o tls=yes -u Server Statistics -m Your server is up and running normally -a /home/admin/stats.txt
THIS has been giving me hell for almost three days now. I've been using Linux as my primary desktop OS for almost a year now and I built my own server about 2 months ago. I saved myself A **TON** of money by using an Open Source/GNU OS and basically "recycling" a buddy's old tower. Current specs as of 02/09/11...



Quote:
Case: Dell Dimension XPS r450
Processor: Pentium II [Deschutes (80523)] @ 450mhz w/ 512mb L2 cache
RAM: 768mb RAM (384mb listed "maximum", hacked it to use 768mb)
HDD: 2 IDE, 2 SATA/USB - 2TB total
OS: Ubuntu 10.04 LTS Server

Original cost (bone stock): $2729 in October 1998

Total cost for me: $200

Long story short, I built the thing up to use as a file server (streaming music/video/TV) and my LANs manager for OSSEC-HIDS, as well as daily backups of all my computers.

I wrote the script to (in essence) take a simple "snapshot" of the current processes/usage and then email it to me at 1100hrs daily via a cronjob.

I could run the script manually from my ~/ directory and it worked beautifully, but as a cronjob, it never updated the *.txt file. So I was receiving the same data on every job, every day for three days.

I did a bit of hacking around with cron and to my amazement (well, not really... I should've figured) it needs a FULLY QUALIFIED DIRECTORY for every time it interacts with a file. My original script said...


Code:
sudo top -b -n 1 > stats.txt
and it needed to be...

Code:
sudo top -b -n 1 > /home/admin/stats.txt

I was in the process of typing out the question hear on LQ when I suddenly had a "light bulb" moment! I edited the script, ran the cron manually and VOILA!! PERFECT!



Perseverance goes a LONG way, my friends!! It's ALWAYS OK to ask questions... but once you can figure it out on your own... trust me, it's the best feeling in the world!!


-Jay
 
Old 02-09-2011, 07:11 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047
You are absolute right. Solving problems oneself is a really good thing.
Just a side-note: There should be no need for sudo here. I would strongly recommend to run commands as root only when needed.
 
  


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: Solving resource contention problems with fuser LXer Syndicated Linux News 0 11-14-2007 06:30 PM
scripting guru wanted (low pay but emotionally rewarding) dasbooter Programming 9 08-16-2005 06:49 PM
solving dependency problems on Suse 9.1 prosh0t Linux - Software 16 03-01-2005 11:09 AM
Solving my Headache Sophic Linux - Wireless Networking 6 03-29-2004 11:27 AM
Solving problems with Linux jamaso Linux - General 3 02-08-2002 06:36 PM


All times are GMT -5. The time now is 02:08 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration