script to tar up files when a partition hits a certain use percentage
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Well, you should IMHO. Sure we'd like to get more people to become self-reliant by knowing what to read and actually reading the manual pages and you did get your point across but there's no need to drive the point home post after post: just once should do.
That said this thread started off on the wrong foot by the OP also not giving a rats *ss about how to talk to other members let alone the fact his "This isn't my first time writing scripts" claim doesn't come across as completely believable...
I learned what I know by reading documentation - because when you read documents, in addition to what you need, you'll pick many additional bits of information that will help you later. When somebody gives you complete solution, you won't get those extra bits of info, and you'll learn less.
Well, you should IMHO. Sure we'd like to get more people to become self-reliant by knowing what to read and actually reading the manual pages and you did get your point across but there's no need to drive the point home post after post: just once should do.
That said this thread started off on the wrong foot by the OP also not giving a rats *ss about how to talk to other members let alone the fact his "This isn't my first time writing scripts" claim doesn't come across as completely believable...
Maybe you are directing this elsewhere besides me, but I thought I asked quite politely for my question. And if you are driving at the fact that I stood my ground to his (or her) BS response to my first post...and still can't see where he (or she) was being a complete a$$ in the response...then you are blind.
I have also asked for this thread to be moved in a couple of different avenues. As far as the poke on about me writing scripts before, fine, believe what you want...but I am not a NAUF on them...I just didn't know how to grab this particular aspect. But I am glad that there are folks out there that can answer simple questions (wasn't anyone here)...without the need to demoralize people (and that last part of the statement includes you as well).
And that's about where it ended as you focused on being argumentative from there on. Sure it's not nice to find there's no immediate silver spooning happening but that should not force you to tell your fellow LQ members to shut up, qualify them as "meaningless response" or a member as "an ass".
Quote:
Originally Posted by dagummit
I have also asked for this thread to be moved in a couple of different avenues.
Not the way it should have been done: by using the report button on your initial post.
Quote:
Originally Posted by dagummit
As far as the poke on about me writing scripts before, fine, believe what you want...but I am not a NAUF on them...I just didn't know how to grab this particular aspect. But I am glad that there are folks out there that can answer simple questions (wasn't anyone here)...without the need to demoralize people (and that last part of the statement includes you as well).
What you should understand is tht there are different ways of learning. Like a lot of members here I prefer the Socratic method. Not only in the hope that asking the right questions helps people to learn but also because it helps me gauge to what extent help is needed. That's why I asked you to post (pseudo) code. If you're this easily miffed then please take that into account next time before you reply, OK?
And that's about where it ended as you focused on being argumentative from there on. Sure it's not nice to find there's no immediate silver spooning happening but that should not force you to tell your fellow LQ members to shut up, qualify them as "meaningless response" or a member as "an ass".
and his first response was all roses? Don't think so... his post was completely unneeded...and quite frankly for a Linux community, very anti-"open source". Heck, he even was disappointed in not getting paid for his 'work'. Of which I would have gladly done if it was allowed, but he painted the path...so he should be able to deal with it. Personally, I don't think he knew the answer to begin with... most people that like to chime in in that manner are nothing more than bogart'ers that don't know the answer to begin with.
Quote:
Not the way it should have been done: by using the report button on your initial post.
I did that, this morning, when reading another posters feedback.
Quote:
What you should understand is tht there are different ways of learning. Like a lot of members here I prefer the Socratic method. Not only in the hope that asking the right questions helps people to learn but also because it helps me gauge to what extent help is needed. That's why I asked you to post (pseudo) code. If you're this easily miffed then please take that into account next time before you reply, OK?
And yet another great example of learning is in fact, learning by example. Sun Tzu used it all of the time...as well as most military and academic settings. To tell someone to 'read the manual' is about as disingenuous as providing mockery of the question (which was also done under this thread...ie, "this is trivial).
And to the posting my code already...as I have already stated...why does that matter? Why was it possible for someone else on a different site able to answer my question without all of the "what ifs"? Sometimes a question can be answered in its basic form without reading into the question (also by Sun Tzu...paraphrased).
The resource you connected with gave you a good script. I only wonder if you may have dissected it to understand how it works.
Here are some other options, maybe not the best coding but they work well.
Perl
#!/usr/bin/perl
open PS, "df -h /var | grep /var |"|| die "Error, cannot open pipe: $!\n";
while(<PS>) {
chomp;
@tmp=split(/\s+/,$_);
$var = substr($pct = @tmp[4],0,2);
}
# what to do if $var > 90
I do have a concern to share with you. 90% disk usage is a little dangerous. No disk drive was ever mean't to be filled up because computers write so heavily to disk it could bring your system down. The general consensus among professionals is that 75% is optimal. 80% is a little edgy but 90% could bring you unhappiness. Computers are not perfect and if your script should fail to run... well you could have a problem.
Hard drives are cheap and the carrier case for them to plug into a USB port is also cheap.
As a parting note, I learned how to write scripts by myself from books and by studying the scripts of others and at times stealing their stuff altogether. Linux is more challenging than Windows or Mac and that is why so many stay away and go with the big boys. Good luck with your backups and your scripting.
Using grep to isolate the actual data from the header is the most expedient way, but only a small amount more of perl or php code would have done as well.
...
...
The resource you connected with gave you a good script. I only wonder if you may have dissected it to understand how it works.
Here are some other options, maybe not the best coding but they work well.
Perl
#!/usr/bin/perl
open PS, "df -h /var | grep /var |"|| die "Error, cannot open pipe: $!\n";
while(<PS>) {
chomp;
@tmp=split(/\s+/,$_);
$var = substr($pct = @tmp[4],0,2);
}
# what to do if $var > 90
I do have a concern to share with you. 90% disk usage is a little dangerous. No disk drive was ever mean't to be filled up because computers write so heavily to disk it could bring your system down. The general consensus among professionals is that 75% is optimal. 80% is a little edgy but 90% could bring you unhappiness. Computers are not perfect and if your script should fail to run... well you could have a problem.
Hard drives are cheap and the carrier case for them to plug into a USB port is also cheap.
As a parting note, I learned how to write scripts by myself from books and by studying the scripts of others and at times stealing their stuff altogether. Linux is more challenging than Windows or Mac and that is why so many stay away and go with the big boys. Good luck with your backups and your scripting.
Using grep to isolate the actual data from the header is the most expedient way, but only a small amount more of perl or php code would have done as well.
...
...
All the best
David
---------- Post added 04-27-11 at 09:48 AM ----------
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.