LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 03-29-2006, 01:13 PM   #1
Paxmaster
Member
 
Registered: Jun 2004
Location: unknown place in NYC
Distribution: Ubuntu
Posts: 377

Rep: Reputation: 30
srcipt issue


How can I make a srcipt that when a directory (/backup) have the size 45 GB or more it will run a other script

thanks
 
Old 03-29-2006, 01:39 PM   #2
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
Here is a untested script I just wrote, it should give you a general idea of where to start.

Code:
#!/bin/sh
SIZE=`df -k | grep backup | awk '{print $3}'`

if [ $SIZE -gt "45000000"]
then
     /usr/local/bin/morethan45gb.sh
else
     /usr/local/bin/lessthan45gb.sh
fi
The only bug in this script is if the volume uses 45000000k exactly, but you can figure that out if you want.

Last edited by ckoniecny; 03-29-2006 at 04:22 PM.
 
Old 03-29-2006, 03:38 PM   #3
Paxmaster
Member
 
Registered: Jun 2004
Location: unknown place in NYC
Distribution: Ubuntu
Posts: 377

Original Poster
Rep: Reputation: 30
I have edit the script to be more easy This is just a test

#!/bin/sh
$SIZE=`du -sh /home/paxmaster/Test/Music.tar | awk '{print $1}'`

if [ $SIZE= -gt "970" ]
then
/home/paxmaster/Test/remove
else
/home/paxmaster/Test/error

but I got an error

./script: line 2: =973M: command not found
./script: line 4: [: -gt: unary operator expected
 
Old 03-29-2006, 04:22 PM   #4
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
First,
Remove the $ sign from SIZE when using it as a variable at the top of your script (follow my example)
Secondly, look at my example, I dont have "= -gt", just "-gt".
 
Old 03-29-2006, 04:34 PM   #5
Paxmaster
Member
 
Registered: Jun 2004
Location: unknown place in NYC
Distribution: Ubuntu
Posts: 377

Original Poster
Rep: Reputation: 30
thanks it work
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shutdown Srcipt Questions Drakkath Mandriva 1 09-08-2005 09:16 PM
Slack 10.1 -- Mouse issue / X11 issue Pozican Linux - General 4 04-19-2005 03:44 AM
webmin issue, poss security issue bejiita Slackware 3 11-03-2004 06:07 AM
DNS issue or caching issue? AZDAVE Linux - Networking 7 10-02-2004 12:28 AM
Having Issue w/ Truetype fonts - Mozilla Issue clove Linux - Software 4 02-18-2004 08:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:09 PM.

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