CPU steal time – how to check

You can easly check steal time of your VPS if you run top command and take a look at the info there.

At the end of the cpu line you should see this:

%Cpu line – end of line…it shows 0.0 st and that means it has cpu all for itself

Now, if you want to make sure steal time readings are correct use something like:

 dd if=/dev/zero | md5sum

This command will make sure your cpu is actually doing something. That way CPU steal time readings will be correct. After running this command on other vps I’m using I have got this:

Now you get the idea. This other VPS is oversold. Without using upper command I get this:

Without dd command used…no real cpu steal time

Let’s try again…

With dd command ran
Without dd command being ran

You should always make sure CPU is being used at that moment in order to get correct CPU steal time numbers…


BitBucket laravel initial commit

I have found it here but since I have older phpstorm there is a way to do it easier


Step 1: Install Bitbucket Linky using this guide. Note Bitbucket Connector is no longer being developed.
Step 2: Set up a new private repository on Bitbucket. If you’re using WordPress, I’d recommend creating a repository for each plugin you are developing, rather than for the entire install. Leave it empty for now.
Step 3 Create a new project in PHPStorm or use an existing one. Click VCS>Create Git Repository. Select the path of your project.
Step 4 Now the repository is properly set up, I then added – using Finder – all of my files into the local repository folder.
Step 5 Select all of your project – which should be in red text – and click VCS>Git>Add. This will have added these files to the project, but not yet pushed them to the remote server.
Step 6 Now select the root directory of your project and click VCS>Git>Commit Directory.
Step 7 Go to VCS>Git>Remotes and add a new remote. You need to get this in Bitbucket by clicking ‘I will be starting from scratch’ and then copying the URL (https://youraccount@bitbucket.org/youraccount/yourrepo.git) and pasting it into PHPStorm.
Step 8 Click VCS>Git>Push. This actually moves the files to the server.
Hope that helps some one – took me ages to figure out. You’re now in the capable hands of many guides on how to use Git.

After step 6 I couldn’t find Remotes so I just clicked on project folder, right click, git->repository->push and then clicked on top remote and then added bitbucket link (https) and all the files were being pushed there.

That’s it.

MySQL import/export dump timestamp problem

I have just lost 4 hours today for a simple export import problem. Why it always has to be that way?!?!?

I had to transfer ip of the domain with the data and of course db. Like always everything was smooth but after trying domain (after dns change) I had to pictures online?!

I have tried everything. Problem was simple (after the battle everyone are generals) – it was mysql :

Dump TIMESTAMP columns in UTC (enables TIMESTAMP columns to be dumped and reloaded between servers in different time zones)

Mysql columns were using timestamps because of the start and end date (23:59:59) for local time BUT when exporting that option was clicked and made strange dates on the importing mysql server.

After unchecking this box time was still strange but at least dates were not going -1 day.

Backup script – simple

If you want to make backups all of your server files (home dir or whatever) you should first make connection without passwords (using ssh).

First choose username you will be using like user981129, make it in server A (with backups). Then do this:

ssh-keygen -t rsa

You have now .ssh folder with public key (id_rsa.pub). Now go to the second server (server B) where backups will be transferred. Go to the /home/someuser and type:

mkdir .ssh; vi authorized_keys;

and then copy .ssh/id_rsa.pub from server A to authorized_keys.

Then on server B chmod .ssh 700; chmod .ssh/authorized_keys 640;

Then on server A make file with chmod a+x something like in /home/user981129:

vi backup.sh

and then paste this:

NOW=$(date +"%m-%d-%Y")
SER="ip of the server where you are transfering files or nameserver"
echo "Backing up data, please wait..."
rsync -avz /home/user981129/admin_backups/admin.root.admin.tar.gz someuser@ipofserverforbackup:/home/someuser/backups/$SER/$NOW/

Then open crontab -e and paste this:

0 3 * * * /home/user981129/backup.sh >/dev/null 2>&1


edit: this post is for me, to speed things up when needed

Copy from folder to folder preserving everything

Either use

sudo cp -rp /home/folder /media/backup/folder

sudo cp -a /home/folder /media/backup/folder (UPDATE: use this one!!!preserves everything)

Or use:

 rsync -avz
-p     same as --preserve=mode,ownership,timestamps

          preserve the specified attributes (default: mode,ownership,timestamps),
          if possible additional attributes: context, links, xattr, all

Source: https://unix.stackexchange.com/questions/43605/how-do-i-copy-a-folder-keeping-owners-and-permissions-intact

Note to myself – ODS and mysql

When importing data you have got from the datacenter (statistical files) use first openoffice .ods format and import it into already built table (copied table with all the structure) and then just import files to that table. Make sure that openoffice sheet is the same name as db table.

If you previously made table (copied table from table you were using before) then the data will just be imported automatically. You might have some problems with columns number but predefined table (copied) must be the same fields count as with .ods file you are importing.

End of note to myself

MySQL rand function

If you need to add some random number to some of the mysql columns then here it goes…

UPDATE tableSET column = FLOOR( 1 + RAND( ) *100 )

The last number (100) means you are about to add any value until 100. So 99, 1, 5, 33, 45…any between 1 and 100.
If you put 10 instead of 100 then you will get between 1 and 10 (2, 5, 6).

Returns a random floating-point value v in the range 0 <= v < 1.0.


That’s it.

Laravel paths explained

For the reference because I tend to forget things sometimes.

// project's root folder    
echo base_path();

// 'app' folder    
echo app_path();        

// 'public' folder but inside app folder and not /home/admin/web/domain.com/public_html
echo public_path();

// 'storage' folder    
echo storage_path();

// 'storage/app' folder    
echo storage_path('app');