Tuesday, June 9, 2015

Build Emacs from source

1. Get emacs from source

$ git clone git://git.savannah.gnu.org/emacs.git

2. Downloaded Packages

$ cd emacs $ ls
admin        ChangeLog.2   doc           leim     m4           nt
autogen.sh   config.bat    etc           lib      make-dist    oldXMenu
BUGS         configure.ac  GNUmakefile   lib-src  Makefile.in  README
build-aux    CONTRIBUTE    INSTALL       lisp     msdos        src
ChangeLog.1  COPYING       INSTALL.REPO  lwlib    nextstep     test

3. Check if you have require tool to build emacs

$ ./autogen.sh
Checking whether you have the necessary tools...
(Read INSTALL.REPO for more details on building Emacs)

Checking for autoconf (need at least version 2.65)...
ok
Checking for automake (need at least version 1.11)...
ok
Your system has the required tools.
Running 'autoreconf -fi -I m4' ...
configure.ac:757: installing 'build-aux/compile'
configure.ac:139: installing 'build-aux/config.guess'
configure.ac:139: installing 'build-aux/config.sub'
configure.ac:136: installing 'build-aux/install-sh'
configure.ac:136: installing 'build-aux/missing'
lib/Makefile.am: installing 'build-aux/depcomp'
Installing git hooks...
‘build-aux/git-hooks/commit-msg’ -> ‘.git/hooks/commit-msg’
‘build-aux/git-hooks/pre-commit’ -> ‘.git/hooks/pre-commit’
‘.git/hooks/applypatch-msg.sample’ -> ‘.git/hooks/applypatch-msg’
‘.git/hooks/pre-applypatch.sample’ -> ‘.git/hooks/pre-applypatch’
You can now run './configure'.

4. Configure

$ ./configure

5. Build emacs

$ make

6. Test Installation

$ src/emacs -Q

7. Deploy the new emacs on your machine

$ sudo make install

Thursday, April 30, 2015

Unix Cron Scheduler

What is a Scheduler

Wiki defines a job scheduler as a computer application for controlling unattended background program execution. i.e if you want your computer to do a task at a particular time without you being there to start the task then you use a scheduler. It could be as simple as playing your favorite song at 6:00 AM every morning to wake you up or finding the most popular post of the day every night.

Cron is the tool that is popular on most Unix/Linux system to setup such tasks.

Scheduling with cron

List all the scheduled jobs on the system.

$ crontab -l

Create or Modify an existing scheduled task.

$ crontab -e

This opens an editor which can be used to modify or add new tasks. You can edit the file and save it.

  • The first line runs the task "rm -Rf /tmp/* > /dev/null" every at 0:00 Hours
  • The second line runs the task "python runDBBackDaily every night at 1:15 AM"

Syntax for cron scheduler

*     *     *     *     *  command to be executed
-     -     -     -     -
|     |     |     |     |
|     |     |     |     +----- day of week (0 - 6) (Sunday=0)
|     |     |     +------- month (0 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

Examples

string
meaning
@reboot
Run once, at startup.
@yearly
Run once a year, "0 0 1 1 *".
@annually
(same as @yearly)
@monthly
Run once a month, "0 0 1 * *".
@weekly
Run once a week, "0 0 * * 0".
@daily
Run once a day, "0 0 * * *".
@midnight
(same as @daily)
@hourly
Run once an hour, "0 * * * *"

Note

Default editor opened by crontab -e can be changed by adding following lines to ~/.bashrc file


export EDITOR="nano"
export VISUAL="nano"

References

1.    https://help.ubuntu.com/community/CronHowto
2.    http://en.wikipedia.org/wiki/Cron