General :: Script To Tar Up Files When A Partition Hits A Certain Use Percentage
Apr 19, 2011
I am in need to create a script that queries how large a partition is and when it hits a certain percentage (say 90%) it will execute another script that tars up certain files (or they could just be part of the same script). I would create a cronjob that runs this script once a day.
I have the script that tars up the files I need, sets permissions, etc. (btw, the files in question are audit logs). I just need the part that runs something like a df -h and takes the use percentage of the /var partition in that query and if that percentage is greater than/ equal to 90%, it kicks off the tar script.
Here is a sniplet of the df -h with just the /var partition shown:
Quote:
So, when the cronjob sees that the Use% is >= 90%, it would kick off the tar script...if not above 90%, it closes.
When I check for updates in Update Manager, instead of downloading the files,goes through the files very quickly and says "Hit" for every file. If I try to update this information manually by running sudo apt-get update, I get this:
Some files have a list of hardware errors (we test electronic components), some have none. If the file name has no errors, I still want to display a message like so
Code: grep ^err R*VER && echo "No error" FILEA.TXT:err->USB3910err FILED.TXT:err No Error
This grep statement works but it seemingly overrides the find() statement above if I run both at the same time... How can I combine the two statements to create a report that lists the filename and error(s) like so
Code: FILEA.TXT Button3320err FILEB.TXT USB3235err FILEC.TXT IR Remote2436err FILED.TXT No error
Is it possible to return "No error" with the file name without error?
I need to execute 20 urls in one shell script and display there responses on the console and write on text file too. consider the case when url is not responding.
In my sudoers file, there are lines that begin with #, lines that begin with % and lines that begin with neither. The # is definitely being used to comment out lines, but what does the % do? Is it a comment marker too?
I am trying to see whether wget can be used to generate actual url hits on a webpage. This does not look good so far�. I changed the following lines in /etc/wgetrc to:
Code: http_proxy=http : / /<proxy_ip>:<port>/ use_proxy on Output :
2011-01-16 12:26:39 (88,9 KB/s) - `index.html.3' saved [50548] This does NOT generate a hit on the actual web page! It does not seem like the, > /dev/null part is working either... How can I get this to work?
My script looks really crap and messy, the logic isn't great and I'm not hugely happy with it. Also it echo's $i instead of an actual IP address (line 10). How to improve this. It basically searches through /var/log/messages for multiple FTP hits and when the hit count is higher than a specific number the IP is added to a config file and ftp is restarted. There are some obvious flaws in my script.
if [ $HITNUMB -gt $MAXHITS ]; then for i in $HIGHIP; do echo $i sed -i '78s/$/,$i/' /opt/etc/proftpd.conf /root/ftp restart done else echo "not greater than $MAXHITS" fi
I'm not even sure what will happen if I get multiple responses for my $TOPHITS. It would be cool if it could search for IP's already blacklisted somehow, it might actually be easier to just create a file with a set of blacklisted IP's or something.
I need something to make a script that will search some logs and extract IP hits from one country only. Let's say UK. I guess I need to use GeoIP or some database. I just need a very simple bash, perl, php script that will do this job. Just search threw logs (apache) and then give me number of hits found from UK.
I haven't recompiled ny kernel in a while, but whenever I did it, it was all pretty easy. Make menuconfig; (adjust); make && make modules_install, and copy over bzImage in */arch/* and System.map to /boot and stick in new entry into grub menu.lst.However, this time, I must be missing something, because I get kernel panic on booting up to the new kernel. Is there a step I'm missing?Certainly, I was looking in /etc/rc.d and there is a rc.modules<kernelver> script in there. I wondered if I need make a new one ... although when I looked over it, it seem only to be required when forcing particular modules.
In OpenSuSE11.2 I followed this url to got it to work: Genius MousePen 8x6 It worked like a charm. In OpenSuSe 11.3 the Xorg stuff is different. In /etc/X11/xorg.conf.d there is a wizardpen.conf but when I use the tablet the mouse hits the top left corner. Using the settings from the url above doesn't make it work either.
it all started with my eagerness to have a triple boot system with XP/Win7/Ubuntu 10.04. I had xp on a PC with an Asus M/B with a single 320GB SATA HDD.Then I installed Win 7 (probably into a logical drive). It went well.Then after searching for some help I installed Ubuntu 10.04 on to another partition. Fine up to here, but when I saw I was able to access other partition files from Linux but not the other way.Then thru some help from some forums I tried to free some space from the Linux Partition and make it as a shared drive between Win and Linux.
In this process I used GParted live CD to rearrange partitions and tried to format the unallocated space it is showing "you cannot create a new volume in this unallocated space because the disk is already containing the maximum number of partitions."
Now I have learned creating partition in linux (ubuntu), well that's an achievement for a newbie. The next thing that I want to know is, how can I copy the contents of a partition to another partition. Like if I want to backup its content to a new partition that Im going to create.
I have Suse 11.2 installed. In Dolphin file manager I can see read files in my windows partition. But I cant create or delete any of these files as a user. I opened Dolphin as root and changed the permission rights of this windows folder so that all groups and users can view and Modify content. But when I try to create something I get the message access denied, "check your permission rights". And how can I change these permission right for my user in console mode?
I installed Ubuntu 10.10 on my PC. During the installation process i selected a partion on my hdd for swap , there i had some important files can i rocover it some how
I backed up all of my files last night via SFTP before I reinstalled Ubuntu *Since nobody answered my question* and I went ahead and encrypted my home folder. How do I open port 22 like Ubuntu normally has it? I've tried this guideBut it didn't work, how do I set up SSH? I really need those files.---------- Post added 07-05-11 at 10:17 AM ----------Also, my Desktop is encrypted, but I forget, but I may have encrypted my laptop since the port is also closed on that as well.
I have an SSH server set up on CentOS 5.5 which I can succesfully use to access my file system remotely.
On this machine, I also have a partition with XP installed on it. Is there a way I can set up the SSH server so that I can remotely access the files on the XP partition?
I dual boot into Arch Linux and OS X 10.6 on my MacBook pro. I synced my UID between both OSes and created an HFS partition (with no journaling) to use as a shared home/Users partition. For the most part it works just as I'd expect, but sometimes when I'm booted into OS X certain files are "locked" (when I get info on a particular file the "Locked" box is checked under the "General" pane. I can resolve the issue by manually unchecking the box) and/or I get "Operation not permitted" when I try deleting or chmod'ing a file. In both cases I don't see anything out of the ordinary on the permission bits displayed with ls -l, except for a trailing '@' character in the position where the sticky bit would normally occur:
This '@' character shows up on ALL normal files, so doesn't seem to be linked to the locked/operation not permission situation.
On the Linux side of things I never have permission problems. To the best of my limited knowledge and experience with ACLs I've not found any ACLs on any of the files in question.
For what it's worth, I do most of my file editing using emacs (Aquamacs in OSX), is it possible it is setting weird permission bits?
What is the "locked" setting that OS X uses and does it have a permission bit equivalent (so at the very least I could recursively unlock all files in my home directory from the terminal) why might some, but not other files get "locked" when booting into OS X what is the meaning of the '@' character?
I've been using Linux for a few years and have managed to find what I need searching (including this great site) until now. I have managed to mess up a substantial partition and don't want to possibly make a bad situation worse by bungling around an area I know next to nothing about. I'll try to explain it fully.I finally built a new PC (750GB internal HDD, 4GB RAM). I'm used to Kubuntu so I installed that (10.04 x86_64bit); partitioned sda1 1GB swap / sda2 OS 20GB ext4 / balance sda3 home ext4 for time being. Everything runs sweet. My old PC (very, PIII, but more recent 500GB internal HDD) partitioned sda1 486.31MB swap / sda2 OS 22.82GB ext4 / balance (442.46GB) sda3 home ext3 (ext3 because /home was inherited from an earlier install prior to Kubuntu going ext4). Old PC was having PSU prob. I don't have an external HDD or any other large HDD and not enough DVDRs for 280GB or so of data current in /home. So I backed up what I could risking the old PC working long enough. Got the critical stuff, business etc. There remained some 150GB or so, years of pictures, videos, info on car repairs etc (some but by no means all on semi annual DVDR backups). Free space current in new PC's /home partition ~500GB. So I took out the HDD from the old PC and put it in the new in order to copy the remainder then use it in the new PC; made sure BIOS of new PC indicated this 2nd drive did not have boot priority. The correct install booted.
To my surprise (maybe not yours?) during boot with zero indication, Kubuntu decided to use the 2nd HDD's /home partition for its new 442.46GB swap partition instead! I was horrified. I unmounted it immediately but... according to GParted the partition with all those files to copy is now:/dev/sbd3 File System: unknown 442.46GB Used: --- Unused: --- no flags
I was surprised by kubuntu changing its partitions without input and assuming a ext3 file system on a secondary HD for a 442.46GB swap partition. But, mistake's on me. Call it a lesson. Now I need to know more but don't want to experiment unduly on this drive and possibly make things worse: What should I do next?
I have some confusion about one of my partition and the space it is taking. df -h output is given below;
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/ddf1_ADVDTARTINGp1 494G 18G 452G 4% /
[code]....
above information is showing that /var/lib/mysql partition total size is 379 GB and it is 68% used. However when I execute command du -sh /var/lib/mysql it shows following output.
# du -sh /var/lib/mysql 45G /var/lib/mysql
Now I want to know what files are taking space to make the partition 68% used. I want to list down all files in that partition with size.
I would like to know if there is a way that I can access my files on the Windows partition using Linux because the Linux partition does not have enough space to house all the files on the Windows partition.
I record my lectures at school using my mobile phone then send them over wifi to my laptop and use a program to do volume correction all in windows. However, I want a exact copy of that folder in my home folder on my ubuntu install on a separate partition.I've been manually copying them over so far but I want to make a script that I can run to copy all new files over. I know a little bit about scripting, mounting the drive and actually copying files is easy, its figuring out how to determine new files and copy only those that I don't know how to do.
My configuration is as Follows: Intel Pentium Dual core 2.6 Ghz 4 GB DDR2 Apacar 800 Mhz RAM Gigabyte ATI Radeon 5450 HD GPU
I'm using Fedora 14 KDE but on startup it uses 40% of my processor. I'm using the proprietary 10.12 AMD ATI Linux Driver. I'm only using blur and woobly windows effect and I'm using OpenGL. Kubuntu/Suse never gave me this trouble. Even GNOME doesn't only KDE and fedora 14 is troubling me.
I know how to set and have set my net-book gz5 running on lucid to stay on at all times.however unlike in xubuntu I don't have the option to change when the computer is critically low. I don't have the room to install xubuntu with my preferred gnome desktop wondered if anyone out thee knows where if there is a .config file that I can dictate the percentage of battery life before being considered critically low. ei now it seems to consider itself low at 15% which robs me of about 2 hours of usage id like to set it around 1%
I didn't know a resize operation on a 750 GB disk was going to take 40+ hours, and I was biting my nails the whole time, until the power went out when "only" 8 hours where left.I can still mount the partition, and many of the files are still there, but some files show as '? ? ? ? ? filename.ext' with ls -l.If I try to go inside such a directory: Input/output error.
I have a separate ext4 partition which contains all my data (music, movies, etc). When I delete files from this partition it is very slow because it copies files from my data partition to the Trash folder in my home partition. How can I avoid this? Can't the trash be configured so that it uses a trash folder in each partition instead of copying files to another partition (which is slow).