Jenkins auto deploying flask in test env with last build process kill and pipenv

export PY=/usr/local/bin/python3
export FLASK_RUN_PORT=4005
$PY -m pip install pipenv
$PY -m pipenv install --dev
export VENV_HOME_DIR=$($PY -m pipenv --venv)
source $VENV_HOME_DIR/bin/activate
flask db upgrade
flask populate-initial-data
export BUILD_ID=XYZapi
flask run &
deactivate can have anything inside it depending upon your project requirements. I put 2 process killers to kill background-ed daemon processes from previous build command

ps -Af | grep "xyzapi" | grep -v grep | awk '{print$2}' | head -1 | xargs kill -9
ps -Af | grep "xyzapi" | grep -v grep | awk '{print$2}' | head -1 | xargs kill -9

Total inode count for a particular user in linux

Inode usage for current working directory

echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"

Use cd ~ to change pwd to current user home

cd ~


Magesh from 2daygeek :

How to solve MySQL server gone away error Maria Db update on cPanel and WHM?

This is related to new MariaDb upgrade from 10.1.41 to 10.1.42 and also for servers which were updated from 10.2.27 to 10.2.28

Go to solution ( Special Thanks to @Valetia )

You will see errors in following formats/messages:

  • No file or input found
  • MySQL Server has gone away
  • Connection to MySQL Server failed
  • sqlstate[hy000]: general error: 2013 lost connection to mysql server during query
  • General error: 2006 MySQL server has gone away
  • ERROR 2006 (HY000): MySQL server has gone away
  • ERROR 2013 (HY000): Lost connection to MySQL server during query

Log files (/var/lib/mysql/$hostname.err) will have or can have any of these errors:

  • assertion fail /home/buildbot/buildbot/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/mariadb-10.2.28/storage/innobase/dict/ line 1467
  • the resulting row size is greater than maximum allowed size (8126) for a record on index leaf page
  • stack_bottom = 0x0 thread_stack 0x49000 mysys/stacktrace.c:268(my_print_stacktrace)[0x5564e62807bb] sql/[0x5564e5d4b4f5]

Other Symptoms:

/etc/init.d/mysql start
Starting MySQL/etc/init.d/mysql: line 159: kill: (10704) – No such process


yum downgrade MariaDB-* -y
whmapi1 update_updateconf RPMUP=manual UPDATES=manual

(run as root #)

This will downgrade MariaDb installation to previous version
Line 2 will cancel automatic update on WHM/CPanel installations

If you are not using WHM, use line 1 only OR you can downgrade the repository individually too

yum downgrade MariaDB-server MariaDB-common MariaDB-shared MariaDB-client MariaDB-compat MariaDB-devel


How to fix Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI error in SSH?

Put this in your bash profile and run source ~/.bashrc

alias composer="/opt/cpanel/ea-php71/root/usr/bin/php /opt/cpanel/composer/bin/composer"

As Composer is now available via WHM you can use this to find it:

which composer

This returned path “/opt/cpanel/composer/bin/composer” for me. If this returns nothing then disregard the rest of this answer, as Composer is not available to you at system level.

You can now use php-cli to call this with Composer’s absolute path:

php-cli /opt/cpanel/composer/bin/composer install
php-cli /opt/cpanel/composer/bin/composer update
php-cli /opt/cpanel/composer/bin/composer require whatever/example

You may however need to alias php-cli if your system claims this isn’t found. It very much depends how PHP has been deployed on the WHM server. Learn how to fix PHP CLI error. You can do this by adding a user alias to the end of your “.bashrc” or “.bash_profile” file as follows:

alias php-cli=/opt/cpanel/ea-php72/root/usr/bin/php

Replace ea-php72 with the release of PHP you want to use. Submit this as a command in the shell to make it available immediately, otherwise it’ll become available when you open your next Bash session.

If you want to make this available with just composer alone you could create this alias again in “.bashrc”:

alias composer=/opt/cpanel/ea-php72/root/usr/bin/php /opt/cpanel/composer/bin/composer


How to edit default python version for a linux user?

Edit the bash profile and add an alias using the following code

$ nano ~/.bashrc

Put the following line of code in .bashrc file and alter the python3.6 path as per your new installation

alias python='/usr/local/bin/python3.6'

Use CTRL x to exit and save
After that you need to reload the source, so use the following command and you are good to go.

$ source ~/.bashrc

Windows v/s Linux. What’s your choice?

Hi Everyone.

Today we are going to talk about the two operating systems. Windows and Linux. Both of them have their own pros and cons.

Offcourse Windows have its monopoly with 88% plus market shares. Although slowly but Linux has started getting attention and getting more popular day by day.

Windows has dominated the market because it is way simpler to operate than any other operating system.

In this article, we will be focusing on understanding the two operating systems and their pros and cons.

So, let’s begin.

What is Windows operating system?

Windows is a series of operating systems, Each operating system comes with a graphical user interface (GUI) with a desktop which allows a user to view all files, videos etc. The first version of Windows OS was released in 1985 which was a simple GUI, an extension of the existing disk operating system (MS-DOS). windows OS comes with almost all company who made PC’s or laptops. Latest Windows OS version is Windows 10 which is currently ruling the market.

What is the Linux operating system?

Based on UNIX Linux is an open source operating system, created in 1991. Users can modify the existing code and create distributions from it as it is an open source operating system. Linux operating system also comes with a graphical user interface (GUI) with some necessary software’s which are used on a daily basis. Linux is mostly used as a server – as most of the web pages over the internet are generated from Linux servers and also used in desktop computers, mobile devices, gaming consoles, digital storing devices, eBook readers, cameras, video recorders have Linux running.



Linux is used by corporate, scientific, and academic organizations of every size. It’s used to power the development machines and servers at Google, Facebook, Twitter, NASA, and the New York Stock Exchange, just to name a few. On the desktop, it is used by technically proficient users who prioritize system security and reliability, and by enthusiasts who want to learn more about computers and how they work. Microsoft Windows is usually the operating system of choice for gamers, novice users, and business users who rely on Microsoft software. Many Windows users are thrilled with the changes that Microsoft has introduced with Windows 10, so if you’ve never used it, now is a great time to try it out.


Linux is a highly secure operating system. Although attack vectors are still discovered, its source code is open and available for any user to review, which makes it easier to identify and repair vulnerabilities. Microsoft has made great security improvements over the years. But as the operating system with the largest user base, especially among novice computer users, it is the primary target for malicious coders. As a result, of all major operating systems, Microsoft Windows is the most likely to be the victim of viruses and malware.


GNU/Linux operating systems have a steeper learning curve for the average user. They frequently require a deeper understanding of the underlying system to perform day-to-day functions. Additionally, troubleshooting technical issues can be a more intimidating and complicated process than on Window. Windows is one of the easiest desktop operating systems to use. One of its primary design characteristics is user-friendliness and simplicity of basic system tasks. Its ease lack of difficulty is considered positive by users who want their system to just work. However, more proficient users may be frustrated by the oversimplification of system tasks at the expense of fine-grained control over the system itself.


So, ultimately it depends on the user.

If your use is just of a normal system which is dammed easy to use, go with Windows 10.

But if you are more of a geek, and would love to customize the system as per your needs, go with LINUX.

depends if i have to watch youtube or code

I had shifted to linux for 2-3 months but could not continue because windows have more gui software than any other known operating system. I like to keep things handy to me all the time, so windows.

I still encounter linux everyday because of ssh and servers

– Harshvardhan Malpani ( Admin)

OK! everyone this is it for today. See you soon.

Thank You.

How to repair a MySQL database?

Hello! Good to see you.

This is going to be a very important article because we are about to discuss  “How to repair a MySQL database?”

Why repair MySQL Database?

Databases can become corrupted for any number of reasons, from software defects to hardware issues.

If this occurs, you can try to repair the database. Wondering how to do it? Just follow this article.


Let’s see how to repair MySQL database through Linux and Windows command line.

Repair MySQL Database through Windows command line.


  • Log in to your Windows VPS using Remote Desktop.
  • Go to Start and locate the Command Prompt. Right-click Command Prompt and select Run as Administrator option.
  • At windows command prompt navigate to MySQL bin directory as follows.
    cd C:\Program Files\MySQL\MySQL Server 5.5\bin  //  Replace your MySQL bin directory path here.
  • Run the following command to start the MySQL prompt.
    mysql -u root -p
  • Enter MySQL root password when you are being asked.
  • You will see MySQL prompt appearing. Now, to display all databases, type following command at MySQL prompt:
    show databases;
  • Enter the following command to repair MySQL database.
    mysqlcheck -r [database] // Replace database name with your database name.

Repair MySQL Database through Linux Terminal.


  • Login to your Linux VPS using Secure Shell (SSH) and connect to MySQL from the command line.
    mysql -uUsername -p // Replace Username with your username.
  • Enter MySQL user password and hit Enter. You will see MySQL prompt appearing. Now, in order to display all databases, type following command at MySQL prompt.
    show databases;
  • mysqlcheck enables you to check databases without stopping the entire MySQL service. -r argument is used to repair the corrupted tables. mysqlcheck utility efficiently works on both MyISAM and InnoDB database engines. Enter the following command to repair MySQL database.
    mysqlcheck -r [database] // Replace database name with your database name.


So, we covered this issue for both Windows and Linux.

Lastly please check our other articles on various topics, that we tried to address.

Thank You.

How to use VestaCP Cli Commands? – Linux

There are a lot of vestacp commands which are useful in automating things but you see error

sudo: v-list-sys-vesta-ssl: command not found

something like this:

sudo /usr/local/vesta/bin/v-add-web-domain-ssl mage yourdomain
/usr/local/vesta/bin/v-add-web-domain-ssl: line 39: /func/ No such file or directory
/usr/local/vesta/bin/v-add-web-domain-ssl: line 40: /func/ No such file or directory
/usr/local/vesta/bin/v-add-web-domain-ssl: line 41: /func/ No such file or directory
/usr/local/vesta/bin/v-add-web-domain-ssl: line 42: /conf/vesta.conf: No such file or directory
/usr/local/vesta/bin/v-add-web-domain-ssl: line 45: format_domain: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 46: format_domain_idn: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 53: check_args: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 54: is_format_valid: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 55: is_system_enabled: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 56: is_system_enabled: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 57: is_object_valid: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 58: is_object_unsuspended: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 59: is_object_valid: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 60: is_object_unsuspended: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 61: is_object_value_empty: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 62: is_web_domain_cert_valid: command not found
cp: cannot stat '/yourdomain.crt': No such file or directory
cp: cannot stat '/yourdomain.key': No such file or directory
cp: cannot stat '/yourdomain.crt': No such file or directory
chmod: cannot access '/ssl/yourdomain.*': No such file or directory
cp: cannot stat '/ssl/yourdomain.crt': No such file or directory
cp: cannot stat '/ssl/yourdomain.key': No such file or directory
cp: cannot stat '/ssl/yourdomain.pem': No such file or directory
/usr/local/vesta/bin/v-add-web-domain-ssl: line 89: get_domain_values: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 90: get_real_ip: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 94: prepare_web_domain_values: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 97: add_web_config: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 110: increase_user_value: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 113: update_object_value: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 114: update_object_value: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 117: /v-restart-web: No such file or directory
/usr/local/vesta/bin/v-add-web-domain-ssl: line 118: check_result: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 120: /v-restart-proxy: No such file or directory
/usr/local/vesta/bin/v-add-web-domain-ssl: line 121: check_result: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 131: log_history: command not found
/usr/local/vesta/bin/v-add-web-domain-ssl: line 132: log_event: command not found


type this in command line (ssh)

export VESTA=/usr/local/vesta/

After that use any command like:

sudo /usr/local/vesta/bin/v-add-letsencrypt-domain <username> <> <*>

Dont use < or > or *
* means optional
< and > means replace your info with that

Complete command list :

How to change PHP versions in VestaCP Ubuntu – Downgrade Upgrade 5.6, 7.1 and 7.2

For Downgrading 7.2 (default) to 7.1 PHP

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install libapache2-mod-php7.1 php7.1 php7.1-bcmath php7.1-bz2 php7.1-cgi php7.1-cli php7.1-common php7.1-curl php7.1-dba php7.1-dev php7.1-enchant php7.1-fpm php7.1-gd php7.1-gmp php7.1-imap php7.1-interbase php7.1-intl php7.1-json php7.1-ldap php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-odbc php7.1-opcache php7.1-pgsql php7.1-phpdbg php7.1-pspell php7.1-readline php7.1-recode php7.1-snmp php7.1-soap php7.1-sqlite3 php7.1-sybase php7.1-tidy php7.1-xml php7.1-xmlrpc php7.1-xsl php7.1-zip
sudo a2dismod php7.2
sudo a2enmod php7.1
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.1

Reference: Sandy B @

Fix Magento 2 – php cli error on cpanel or other hostings

The problem:

On a fresh install of Magento2 on cpanel based hosting, you receive the following error while running any command on SSH

[[email protected] www]$ php bin/magento cache:clean
X-Powered-By: PHP/7.0.31
Content-type: text/html; charset=UTF-8
bin/magento must be run as a CLI application
[[email protected] www]$ php bin/magento setup:upgrade
X-Powered-By: PHP/7.0.31
Content-type: text/html; charset=UTF-8
bin/magento must be run as a CLI application

The Solution:

You have to point php to correct binary;
Use the following code in order:
First, open the file which can alter the runtime variables like .bash_profile or .bashrc

cd ~ ; nano .bash_profile
cd ~ ;nano .bashrc

Go to last line and paste this (depending upon php version change ea-php71 or ea-php70):

alias php='/opt/cpanel/ea-php71/root/usr/bin/php'

Save the file and exit the editor.
Log out and login again OR use the following command

$ source ~/.bashrc

If you are not sure about current php version, use which php or php -v command. If you think the cpanel configuration is the issue, fix EasyApache 4 PHP cli issue. With this way you can fix the setting and enable the new php version