- Member Success Stories (
-   -   Solving problems on your own is VERY rewarding!! (

ncn8ochaser 02-09-2011 06:57 PM

Solving problems on your own is VERY rewarding!!
I'm going to make this rather quick but I just want to say this...



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

sudo sendEmail -v -f -s -xu myusername -xp mypasswd -t -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...


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...


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


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!!


TobiSGD 02-09-2011 07:11 PM

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.

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