Tag Archives: Linux

Django – Schedule django-admin command using django-chronograph

Previously we talked about setting up some custom command in a Django project.

 

I would like to run the custom command in a regular interval. I could use Linux cronjob but it’s hard to manage and check the run history. It would be great if i could setup and manage these scheduled commands on the Django web portal.

django-chronograph, written by wnielson, is a Python Package which allows us to schedule any django-admin command through the web interface. It works well with the UTC timezone but if you have set the TIME_ZONE in your Django project setting.py, there would be time discrepancy.

For more detail about the bug, you can refer to the Issue #36 – Job doesn’t follow the Django’s TIME_ZONE setting.
Continue reading

About these ads

Install Graphite under pyenv virtualenv on Ubuntu

It took me one and an half day to get the Graphite working…

1. Make sure you have pyenv and pyenv-virtualenv installed.

 

2. Install the following packages.

sudo apt-get install python-dev pkg-config libcairo2-dev memcached

 

3. Install Python 2.7 with enable-shared.

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 2.7.8

Continue reading

Ubuntu – Install Monit

Monit is a opensource monitoring tool on Unix system. The simplest use case would be restarting your service if there is failure.

On Ubuntu, simply run apt-get to install Monit.

sudo apt-get install monit

 

The Monit folder is at /etc/monit. Before you can read anything from Monit, create the /etc/monit/conf.d/monit.conf in order to setup the Monit web interface.

set httpd port 2812 and
  use address localhost
  allow localhost

Continue reading

Housekeeping Puppet Master

Yesterday i used a Puppet master as an example to talk about purging old files on Linux.

Of course we can setup a cron job and run the shell command daily for housekeeping. But as we are using Puppet, we don’t we do that thru Puppet manifest?

tidy { 'puppet::reports':
  path => '/var/lib/puppet/reports',
  matches => '*.yaml',
  age => '14d',
  backup => false,
  recurse => true,
  rmdirs => false,
  type => 'ctime',
}

 

The above tidy type will delete those .yaml which is older than 14 days.

Done =)

Reference: Google Groups – Purge puppet’s reports

Linux – Delete files which are older than N days

One day i found that the Puppet master is running out of space and then i realize that there is a lot of run reports in YAML format located @ /var/lib/puppet/reports. I want to delete the old reports for releasing the disk space.

So i move to the /var/lib/puppet/reports directory and execute the following line to recursively remove any .yaml which is older than 14 days.

find $d -type f -name \*.yaml -mtime "+14" -exec rm -f {} \;

 

A few years ago i had a post about a housekeeping shell script which is quite similar to the above approach.

Done =)

Reference: Google Groups – Purge puppet’s reports

Ubuntu – Install Node Ver­sion Man­ager globally for all users

The Node Ver­sion Man­ager(nvm) could help you to manage multiple Node.js installations. The following steps are executed from root account.

1. Install the required packages.

apt-get install build-essential openssl libssl-dev curl

 

2. Create a new user group and add those users which are allowed to manage Node.js installation. The following command create a new group called dev.

groupadd dev

Continue reading

Shell Script – Check file owner and other attributes

Here is a simple shell script which would read a user input and return you the owner and group of the input path.

check_owner_and_group.sh

#!/bin/sh

echo "Please enter a file/folder path:"
read target_path
echo "You have entered $target_path"

if [ -e $target_path ]; then
  target_owner=$(stat -c %U $target_path)
  target_group=$(stat -c %G $target_path)

  echo "$target_path owner is: $target_owner"
  echo "$target_path group is: $target_group"
else
  echo "$target_path is not a valid path"
fi

Continue reading