Checking download time from url list by wget

Prepare file with url resources, chrome – F12 – network tab – right click – save as HAR

cat urllist | grep '"url"\:' |sed 's/\"\url\"\://g' | sed 's/"//g' | sed 's/,$//g' > resultfile
time cat resultfile | xargs -t -P 8 -n1 wget

That’s way we’ll check download our resources by wget in 8 streams

How convert unix time

date -jr 1333696934
Fri Apr  6 11:22:14 MSK 2012

bash: rsync: command not found

The problem:

bash: rsync: command not found
          rsync: connection unexpectedly closed.......
          rsync error: remote command not found code (127) at io

Solution: rsync should be installed on both the local and remote computer

Freebsd. Undeletable flag on the file

Enable the system undeletable flag on the file file1, issue the following command:

chflags sunlink file1

And to disable the system undeletable flag, issue the previous command with “no” in front of the sunlink. Observe:

chflags nosunlink file1

To view the flags of this file, use the ls(1) command with the -lo flags:

ls -lo file1

Use -R for directories

chflags -R sunlink  /folder

Converting a table in the mysql server

Let’s see what engine our tables use:

  mysql -e "use database; show table status where Engine LIKE '%MyISAM%'" | awk '{print $1}'

Convert them

 alter table TABLE1 engine=InnoDB;

How to reset root password

Freebsd:

boot -s #single mode
mount -u /
mount -a
passwd
exit

Linux

-s # single mode
passwd
init 5 # default level

How to create a freebsd package

Hi, let’s see how to build a package:

pkg_info | grep php52-pcre
pkg_create -b php52-pcre-5.2.17

that’s it, we’ve got a php52-pcre-5.2.17.tbz
And install it to another server:

pkg_add php52-pcre-5.2.17.tbz

How much time in mysql?

Some information about date and time in the mysql:

SELECT CURDATE();
SELECT CURTIME();
SELECT NOW();
SELECT NOW() + 0; #unix timestamp

more info:

Uniq file names for backup operation

I use such name:

filename.tar.`date +%d.%m.%y_%H.%M`.gz

For auto delete expired files:

find /somebackup/*.gz -type f -mtime +30 -exec rm {} +

Nginx. The distribution of client connections between workers

If You make a tuning of webserver, you maybe wish to know this information. So, let’s start:

fstat | grep 'nginx.*tcp' | awk '{print $3}' | sort | uniq -c

For, example You see that it isn’t correct, You can try to fix it:

events {
   accept_mutex  off;
}