/bin/tar: Argument list too long

Sometimes you have too many files in a directory for tar to handle

so

tar -cvf jan2010.tar *.xml

does not work and you get

/bin/tar: Argument list too long

They way I got around this was to use find

find . -name ‘*.xml’ -print > /tmp/tar_list
tar -cvzf jan2010.tar.gz –files-from /tmp/tar_list
find . -name ‘*.xml’ -exec rm -f {} ;

Advertisements
/bin/tar: Argument list too long

Changing Settings for all tables

As part of my migration to MariaDB I wanted to change all the wordpress tables from MyISAM to INNODB. Of course you can do this one table at a time with

alter table fred engine=innodb;

Personally I prefer to automate where ever possible so  I created the following linux shell script to convert all the tables in one database in one go

DBNAME=”blog”
DBUSER=”xxxx”
DBPWD=”xxxxxxxx”
for t in $(mysql -u$DBUSER -p$DBPWD –batch –column-names=false -e “show tables” $DBNAME);
do
echo “Converting table $t”
mysql -u$DBUSER -p$DBPWD -e “alter table $t engine=innodb” $DBNAME;
done

This script could of course be used for many things by just changing the SQL in line 7

Changing Settings for all tables

Stored Procedures for Killing connections

DROP PROCEDURE IF EXISTS kill_host;

DELIMITER $$


CREATE PROCEDURE kill_host( hostnamein varchar(60))
BEGIN


DECLARE CURCONN int;


SET CURCONN=(select connection_id());


SET @CNT = (
select count(*)
from information_schema.processlist
where ID CURCONN
AND HOST like CONCAT(hostnamein ,”:%”)
);


SET @VAR=1;


WHILE ( @VAR <= @CNT) DO SET @TID = ( select id from information_schema.processlist where ID CURCONN and
HOST like CONCAT(hostnamein ,”:%”) limit 1
);


SET @k = CONCAT(“kill ” , @TID);
PREPARE killcom FROM @k;
EXECUTE killcom;
set @k=NULL;


SET @VAR=@VAR+1;


END WHILE;




END$$


DELIMITER ;


DROP PROCEDURE IF EXISTS kill_user;

DELIMITER $$


CREATE PROCEDURE kill_user( usernamein varchar(60))
BEGIN


DECLARE CURCONN int;




SET CURCONN=(select connection_id());




SET @CNT = (
select count(*)
from information_schema.processlist
where ID CURCONN
AND USER = usernamein
);


SET @VAR=1;


WHILE ( @VAR <= @CNT) DO SET @TID = ( select id from information_schema.processlist where ID CURCONN and
USER = usernamein limit 1
);


SET @k = CONCAT(“kill ” , @TID);
PREPARE killcom FROM @k;
EXECUTE killcom;
set @k=NULL;


SET @VAR=@VAR+1;


END WHILE;




END$$


DELIMITER ;

Stored Procedures for Killing connections