Category: UNIX/Linux

UNIX/Linux related article

How to create edit/extract initrd in Ubuntu/Debian and Redhat/Fedora Linux ?

How to create edit/extract initrd in Ubuntu/Debian and Redhat/Fedora Linux ?

Introduction ~

Long back I edited initrd as  old linux (Ubuntu 6.06) box was not able to boot with SCSI hard disk? One of my friend wanted to do the same for other purpose. So got a chance to write article on the same? Let’s start with what is initrd?

What is initrd ?

initrd (Initial Ram Disk) is a temporary file system ( used as /) commonly used in the boot process of the Linux kernel. It is typically used for making preparations before the real root file system can be mounted.

Why someone want to edit/modify initrd ?

I assume that you all are familier with Linux booting process? Once Linux kernel loaded in to memory (RAM) it start init (father/mother of all  process) process. is that true? Let me ask you one question. Before loading actual physical root file system (/) how kernel access /sbin/init script? what is the use by specifying “initrd” file in GRUB ?  hold on!!

Suppose your root partion resides on some SCSI device and driver for this SCSI devices is compiled as a kernel module. Of course this module is required at boot time to have access to the root partion — but it is not in the kernel. Thus the need for an initrd image. Additionally after udev subsystem become common, somebody has to start udev to create device nodes. This is initrd’s duty too.

See the GRUB menu as shown below ~

title        Ubuntu 9.04, kernel 2.6.28-11-generic
kernel        /vmlinuz-2.6.28-11-generic root=/dev/sda3  ro quiet splash
initrd        /initrd.img-2.6.28-11-generic

GRUB loads  kernel and initrd image in to memory(RAM). When kernel boots  it checks for initrd image, and if it exists starts init script that resides on this image. init script is usually written in bash. When init script on initrd image is finished, kernel usually start standard init process ie /sbin/init

Step 1] Copy original initrd image file to temp location  ~

** Create temporary directory and copy initrd file in that temp directory

arunsb@laptop:~$ cp /boot/initrd.img-2.6.28-11-generic  /tmp/

arunsb@laptop:~$ mkdir /tmp/initrd-src

** Now extract “initrd” image –

arunsb@laptop:~$ cd /tmp/initrd-src

arunsb@laptop:/tmp/initrd-src$ gzip -dc  /tmp/initrd.img-2.6.28-11-generic  | cpio -id
38791 blocks
arunsb@laptop:/tmp/initrd-src$ ls -l
total 36
drwxr-xr-x 2 arunsb arunsb 4096 2009-07-12 16:32 bin
drwxr-xr-x 3 arunsb arunsb 4096 2009-07-12 16:32 conf
drwxr-xr-x 6 arunsb arunsb 4096 2009-07-12 16:32 etc
-rwxr-xr-x 1 arunsb arunsb 4825 2009-07-12 16:32 init
drwxr-xr-x 5 arunsb arunsb 4096 2009-07-12 16:32 lib
drwxr-xr-x 2 arunsb arunsb 4096 2009-07-12 16:32 sbin
drwxr-xr-x 8 arunsb arunsb 4096 2009-07-12 16:32 scripts
drwxr-xr-x 3 arunsb arunsb 4096 2009-07-12 16:32 usr
arunsb@laptop:/tmp/initrd-src$

** Check how “init” looks like ~

arunsb@laptop:/tmp/initrd-src$ head init
#!/bin/sh

echo “Loading, please wait…”

[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir -m 0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
mkdir -p /var/lock
arunsb@laptop:/tmp/initrd-src$

Step 2] Edit/Modify as per your requirement

Step 3] How to create initrd image  ~

Create initrd image from scratch –

root@laptop:/home/arunsb# mkinitramfs  -v -o  /tmp/initrd-arun-$(uname -r)

root@laptop:/home/arunsb# ls -l /tmp/initrd-arun-2.6.28-11-generic
-rw-r–r– 1 root root 7536506 2009-07-12 17:11 /tmp/initrd-arun-2.6.28-11-generic

root@laptop:/home/arunsb# du -sh /tmp/initrd-arun-2.6.28-11-generic
7.2M    /tmp/initrd-arun-2.6.28-11-generic
root@laptop:/home/arunsb#

mkinitramfs ~ is the tool used to create initrd image. “initrd” image is a gzipped cpio archive.

** After all modifcation create initrd image as shown below…

arunsb@laptop:/tmp/initrd-src$ find . | cpio –quiet –dereference -o -H newc | gzip -9 > /tmp/initrd.img-2.6.28-11-arun
arunsb@laptop:/tmp/initrd-src$ ls -l /tmp/initrd.img-2.6.28-11-arun
-rw-r–r– 1 arunsb arunsb 7505955 2009-07-12 16:56 /tmp/initrd.img-2.6.28-11-arun
arunsb@laptop:/tmp/initrd-src$

* Enjoy !!

Regards,
Arun Bagul

openlsm-0.99 released

openlsm-0.99 released

Dear All,

We are pleased to announce that the openslm-0.99 development platform released on 10th Jun 2009. We are sure that  all contributor’s of openlsm and IndianGNU.org community will start coding for openlsm…

* Please don’t forget to test openlsm and give your valuable feedback/suggestion!

community Blog – http://www.indiangnu.org/

Download openlsm ~

* http://openlsm.sourceforge.net/
http://sourceforge.net/project/showfiles.php?group_id=211420

What is openLSM?

openLSM is web-based control panel designed to make administration of website, GNU/Linux and Unix based operating system easy! openLSM handles all aspects of administration in its interface. It is free/open source software under GPL.

How to install openlsm ~

step 1) cd to the source directory

   ./configure --prefix=/usr/local/openlsm
    OR
    ./configure --prefix=/usr/local/openlsm --with-mysql=/usr/bin/mysql_config --enable-internal-pcre
    --with-geoip=/usr --with-ldap=/usr 	

   make
   make install
step 2) openLSM is using 'openlsm' user and group. please create system user and group and set homedir
    /usr/local/openlsm or 'prefix' value. Confirm ownership/permission of '/usr/local/openlsm'
     directory after installation.

  addgroup --system openlsm
  adduser --system  --home /usr/local/openlsm --shell /bin/false --gid <gid_of_openlsm_group>  openlsm

step 3) How to create a self signed certificate for SSL/TLS

 dd if=/dev/random  of=/tmp/random.dat bs=1024 count=1

 $ openssl genrsa   -out  /usr/local/openlsm/etc/openlsm/ssl/openlsm-certificate.key
    -rand /tmp/random.dat 2048
 $ openssl req -new -key /usr/local/openlsm/etc/openlsm/ssl/openlsm-certificate.key
   -out /usr/local/openlsm/etc/openlsm/ssl/openlsm-certificate.csr

 #generate certificate
 $ openssl x509 -req -days 365 -set_serial 1 -in
  /usr/local/openlsm/etc/openlsm/ssl/openlsm-certificate.csr
   -signkey /usr/local/openlsm/etc/openlsm/ssl/openlsm-certificate.key
   -out /usr/local/openlsm/etc/openlsm/ssl/openlsm-certificate.crt

step 4) please check permission, ownership of /usr/local/openlsm directory and file
        path in openlsm.conf  configuration file...

start openlsm with script in  contrib directory…

./contrib/openlsm start

URL ~ http://<server_name_or_ip>:4050/ or

http://<server_name_or_ip>:4060/

enjoy !!

Regards,
IndianGNU & openlsm

Epoch or Unix timestamp and Date format

Epoch or Unix timestamp and Date format

What is Epoch time ?

Unix time, or POSIX time is also know as Epoch time. Linux/Unix operating systems maintain system time based on some starting time called the Epoch. In Linux/Unix and POSIX systems count time as seconds since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds. It is widely used not only on Unix-like operating systems but also in many other computing systems. Epoch time is in seconds!!

1] How to get Epoch time ?

* Linux / Ubuntu

root@arun:~# date
Wed Jan 28 23:52:12 IST 2009

root@arun:~# date +%s
1233166934
root@arun:~#

* FreeBSD

root@arun:~# date
Wed Jan 28 11:07:10 IST 2009

root@arun:~# date  +%s
1233169634
root@arun:~#

2] How to convert Epoch time into Date format ?

* Linux / Ubuntu

arunsb@arun:~$ date -d ‘1970-01-01 1233167307 sec’
Wed Jan 28 18:28:27 IST 2009
arunsb@arun:~$

* FreeBSD

arunsb@arun:~# date -r 1233169468
Wed Jan 28 11:04:28 IST 2009
arunsb@arun:~#

3] How to convert Date time into Epoch ?

* Linux / Ubuntu

arunsb@arun:~$ date ; date +%s
Thu Jan 29 00:26:48 IST 2009
1233169008
arunsb@arun:~$ date -d ‘Thu Jan 29 00:26:48 IST 2009’ +%s
1233169008
arunsb@arun:~$ date -d ‘Thu Jan 29 00:26:48 IST 2009’ +%s
1233169008
arunsb@arun:~$

* FreeBSD

root@arun:~#  date -j -f ‘%Y-%m-%d %H:%M:%S %Z’ ‘2009-01-29 00:50:04 PST’ +%s
1233219004

root@arun:~#  date -j -f ‘%Y-%m-%d %H:%M:%S %Z’ ‘2009-01-29 00:50:04 GMT’ +%s
1233190204
root@arun:~#

Thanks,
Arun Bagul

How to convert nero image to iso image and extract iso image

How to convert nero image to iso image and extract iso image

Introduction –

nrg2iso is handy tool to convert Nero Image to ISO image

* How to install nrg2iso on Ubuntu Linux –

root@arun:~# apt-get  install   nrg2iso
root@arun:~/oracle-setup# nrg2iso -h
Nrg2Iso v0.4 by G. Kokanosky
released under the GNU GPL v2 or later

Usage :
nrg2iso image.nrg   image.iso

–version    display version number
–help       display this notice

root@arun:~/oracle-setup#

* How to use it ? –

root@arun:~/oracle-setup# ls
ora92linux.nrg
root@arun:~/oracle-setup#

root@arun:~/oracle-setup# nrg2iso ora92linux.nrg  ora92linux.iso
|==============================>[100%]
ora92linux.iso written : 680659100 bytes
root@arun:~/oracle-setup#

root@arun:~/oracle-setup# ls *.iso
ora92linux.iso
root@arun:~/oracle-setup#

* Now ISO image is ready, we can mount ISO image to extract the data as shown below….
root@arun:~/oracle-setup# mount -o loop  ora92linux.iso   /tmp/mount-iso/
root@arun:~/oracle-setup#

root@arun:~/oracle-setup# cd  /tmp/mount-iso/
root@arun:/tmp/mount-iso# ls
doc  index.htm  install  lgto  response  runInstaller  stage
root@arun:/tmp/mount-iso#

root@arun:/tmp/mount-iso# ls
doc  index.htm  install  lgto  response  runInstaller  stage

* Enjoy!! – you can copy the extracted data where ever you want!!

root@arun:/tmp/mount-iso# cp -fr * /root/oracle-setup/oracle-1/
root@arun:/tmp/mount-iso#

root@arun:~/oracle-setup# mount
/root/oracle-setup/ora92linux2.iso  on  /tmp/mount-iso type iso9660 (rw,loop=/dev/loop0)
root@arun:~/oracle-setup#

* Un-mount to ISO image –

root@arun:/tmp/mount-iso# cd  /
root@arun:/# umount /tmp/mount-iso/
root@arun:/#

Thank you,

Arun Bagul

How to create, copy and burn or write ISO image

How to create, copy and burn or write ISO image

Introduction –

An ISO 9660 is file system for CD-ROM media. Which is published (defined) by the International Organization for Standardization (ISO). ISO image is an archive file (disk image) of an optical disc (like CD) using a conventional ISO 9660 format that is widely supported by many OS and software.

1] How copy  data from ISO image –

I just downloaded opensolaris ISO  image. and wanted copy data from iso image.

step 1) I downloaded the image in /opensolaris  directory

root@arun:/opensolaris# ls -l
total 700768
-rw-r–r– 1 root root 716881920 2008-08-26 06:21 opensolaris-200805.iso
root@arun:/opensolaris#

step 2) mount the ISO image  as  shown below –

root@arun:/opensolaris# mount -o  loop  /opensolaris/opensolaris-200805.iso   /mnt/
root@arun:/opensolaris#

* Check mount point…

root@arun:/mnt# mount  | grep iso
/opensolaris/opensolaris-200805.iso on /mnt type iso9660 (rw,loop=/dev/loop0)
root@arun:/mnt#

step 3) Go to  mounted directory ie /mnt (in my case) –

root@arun:/opensolaris# cd /mnt/
root@arun:/mnt# ls
bin     boot  bootcd_microroot  COPYRIGHT  dev  devices  jack  LICENSE  mnt  platform  proc
reconfigure  root  solarismisc.zlib  solaris.zlib  system  tmp
root@arun:/mnt#

2] How to create ISO image –

a) using dd command  we can create iso image of CD

dd if=/dev/cdrom  of=/tmp/mycdimgage.iso

b) using mkisofs command we can create iso image of our data in any directories

** mkisofs command –

    -R, -rock                               Generate Rock Ridge directory information
    -o FILE, -output FILE             Set output ISO file name
    -l, -full-iso9660-filenames    Allow full 31 character filenames for ISO9660 names
    -max-iso9660-filenames      Allow 37 character filenames for ISO9660 names (violates ISO9660)
    -input-charset CHARSET      Local input character for file name conversion
    -output-charset CHARSET   Output character set for file name conversion

    root@arun:~# mkisofs  -input-charset utf-8  -R -o  /tmp/mycdimage.iso  /mnt/
    1.43% done, estimate finish Sun Oct 10 17:53:05 2008
    2.86% done, estimate finish Sun Oct 10 17:52:30 2008

    ….
    98.56% done, estimate finish Sun Oct 10 17:52:25 2008
    Total translation table size: 0
    Total rockridge attributes bytes: 22651
    Total directory bytes: 159744
    Path table size(bytes): 1024
    Max brk space used 21000
    350039 extents written (683 MB)
    root@arun:~#

    * checking the Size of ISO image of /mnt directory

    root@arun:~# du -sh /tmp/mycdimage.iso
    685M    /tmp/mycdimage.iso
    root@arun:~#

    3] How Burn (copy) ISO image to CD –

    cdrecord is the command line tool to burn or write  iso image file to CD

    ** cdrecord command –

      -v                       Verbose i.e show info while burning the disk
      -dev=0,0,0        Device number
      -multi                 Start multi session disk
      -data                  This option required for HP and Sony CD Writer only.
      -scanbus            scan the SCSI and IDE buses and exit
      -dummy             do everything with laser turned off
      -eject                  Ejects the CD when Done
      -speed=12                  Writing speed (12x )
      -msinfo                        retrieve multi-session info for genisoimage
      timeout=                     set the default SCSI command timeout to
      /tmp/mycdimage.iso   Name of iso image  which to be burned

      * How  to  get Device number ?

      root@arun:~# cdrecord -scanbus
      scsibus3:
      3,0,0   300) ‘MATSHITA’ ‘UJDA775 DVD/CDRW’ ‘1.00’ Removable CD-ROM
      ….
      root@arun:~#

      root@arun:~# cdrecord -dev=3,0,0 -multi -data -v -eject -speed=4 /tmp/mycdimage.iso

      NOTE – above device naming convention doesn’t work in Ubuntu use device  file directly…

      root@arun:~# cdrecord  -dev=/dev/cdrom  -multi -data -v -eject -speed=4 /tmp/mycdimage.iso

      TOC Type: 1 = CD-ROM
      scsidev: ‘/dev/cdrom’
      devname: ‘/dev/cdrom’
      scsibus: -2 target: -2 lun: -2
      Linux sg driver version: 3.5.27
      Wodim version: 1.1.6

      ….
      communication breaks or freezes immediately after that.
      FIFO size      : 12582912 = 12288 KB
      Track 01: data     0 MB         padsize:  242 KB
      Total size:        0 MB (00:04.02) = 302 sectors
      Lout start:        1 MB (00:06/02) = 302 sectors

      root@arun:~#

      ** Hey, just mount the CD and see

      NOTE – Brasero CD burning (http://www.gnome.org/projects/brasero/) – GNOME tool for writing/burning CD is included in Ubuntu 8.04!!

      Thank you,
      Arun Bagul

      apt-get installation for Redhat based Linux

      apt-get installation for Redhat based Linux

      Introduction –  apt-get  is the  APT package handling utility. I am using  apt-get command for  my day to day activities, which is very handy tool on Debian/Ubuntu Linux. Which can be used for installing/updating or removing Debian package (.deb), updating system etc.  So I was thinking  about using  apt-get on Redhat (RPM) based Linux.  is there any way to use it? the answer is Yes!! there is way  to use  apt-get  on Redhat (RPM) based Linux.

      root@localhost:~#rpm -ivh http://apt.sw.be/redhat/el4/en/x86_64/dag/RPMS/apt-0.5.15lorg3.2-1.el4.rf.x86_64.rpm

      Add following mirror –

      root@localhost:~# vi /etc/apt/sorces.list.d/os.list

      repomd http://apt.sw.be redhat/el4/en/x86_64/dag/

      root@localhost:~#

      How to use apt-get –

      root@localhost:~# apt-get upgrade

      root@localhost:~# apt-get update

      root@localhost:~#apt-cache  search  pkg_name

      root@localhost:~#apt-get  install  pkg_name

      root@localhost:~#apt-get  remove  pkg_name

      Thanks
      Ravi Bhure

      crontab – How it works?

      crontab – How it works?

      Introduction – cron is a daemon to execute scheduled commands (Vixie Cron). cron daemon has following options…

      cron [-f] [-l] [-L loglevel]

      Options
      -f Stay in foreground mode, don’t daemonize.

      -l Enable LSB compliant names for /etc/cron.d files

      -L loglevel

      Sets the loglevel for cron. The standard logging level (1) will
      log the start of all the cron jobs. A higher loglevel (2) will
      cause cron to log also the end of all cronjobs, which can be
      useful to audit the behaviour of tasks run by cron. Logging
      will be disabled if the loglevel is set to zero (0).

      There are two type of cron job (crontab) –

      1) User based cron job (crontab) –
      2) System wide cron job (crontab) –

      1] User based cron job (crontab) –

      cron daemon searches its spool directory “/var/spool/cron/crontabs” for crontab files. After scheduling cron job by any user, the cron daemon will create file with that user name in it’s spool directory to store cron job for that user. Then cron daemon will load all cron jobs which are scheduled for each user into memory by reading contab file for each user from this spool directory. Please note that crontabs in this directory should not be accessed directly the crontab command should be used to access and update them.

      root@arunbagul:~# ls -l /var/spool/cron/crontabs/
      total 8
      -rw——- 1 arun crontab 265 2008-03-31 19:22 arun
      -rw——- 1 root crontab 317 2008-03-31 19:57 root
      root@arunbagul:~#

      root@arunbagul:~# ls -dl /var/spool/cron/crontabs/
      drwx-wx–T 2 root crontab 4096 2008-03-31 19:57 /var/spool/cron/crontabs/
      root@arunbagul:~#

      root@arunbagul:~# grep crontab /etc/group
      crontab:x:111:
      root@arunbagul:~#

      ** root is the owner and crontab is the group owner of spool directory of cron daemon ie “/var/spool/cron/crontabs/”. The crontab files in spool directory is owned by respective user and group owner is “crontab”. please note the permission of spool directory and crontab files. As sticky bit is assigned on spool directory. only user can delete the crontab file(of course root also!).

      For example – As shown below the crontab for user “arun” are stored in file “arun” in spool directory ie “/var/spool/cron/crontabs/arun” file.

      root@arunbagul:~# cat /var/spool/cron/crontabs/arun

      * 0 * * * /home/arun/update.sh

      root@arunbagul:~#

      How to start/stop/restart the cron daemon –

      root@arunbagul:~# /etc/init.d/cron
      * Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload}
      root@arunbagul:~#

      root@arunbagul:~# /etc/init.d/cron start
      * Starting periodic command scheduler crond [ OK ]
      root@arunbagul:~#

      root@arunbagul:~# /etc/init.d/cron restart
      * Restarting periodic command scheduler crond [ OK ]
      root@arunbagul:~#

      root@arunbagul:~# /etc/init.d/cron stop
      * Stopping periodic command scheduler crond [ OK ]
      root@arunbagul:~#

      NOTE – No need to reload the cron daemon after modifying the crontab file by any user.

      2] System wide cron job (crontab) –

      System wide setting for crontab is defined in “/etc/crontab” file and in “/etc/cron.d/” directory. The intended purpose of this feature is to allow packages that require control of their scheduling. The packages can add there crontab files to /etc/cron.d directory and such files should be named after
      the package that supplies them. For example the crontab “/etc/cron.d/php5” is set by php5 package. see below… But this is not the case alway! You can use this features for customized scheduling!!

      root@arunbagul:~# ls -l /etc/cron.d/
      total 8
      -rw-r–r– 1 root root 244 2007-03-05 12:08 anacron
      -rw-r–r– 1 root root 456 2007-10-05 05:06 php5
      root@arunbagul:~#

      root@arunbagul:~# cat /etc/cron.d/php5
      # /etc/cron.d/php5: crontab fragment for php5

      # Look for and purge old sessions every 30 minutes
      09,39 * * * * root [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -r -0 rm
      root@arunbagul:~#

      root@arunbagul:~# cat /etc/crontab
      SHELL=/bin/sh
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

      # m h dom mon dow user command
      17 * * * * root cd / && run-parts –report /etc/cron.hourly
      25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
      47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly )
      52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )
      #
      root@arunbagul:~#

      a) Hourly crontab(job) –

      Setting for hourly crontabs is defined /etc/crontab file . Let’s see what is there in above /etc/crontab file. First and second line in /etc/crontab file defines SHELL and executable PATH variables respectively and third line is comments.

      Now we will see fourth line…

      17 * * * * root cd / && run-parts –report /etc/cron.hourly

      cron daemon will run the command “cd / && run-parts –report /etc/cron.hourly” at 17th minute of every hour as “root” owner. Lets see what this command is doing. “&&” operator means that if first command is successful then only execute the second command (see example below) ie “&&” is logical AND. The first command is “cd /” which will set pwd as /. Once this command is successful, next command “run-parts –report /etc/cron.hourly” will be executed..

      root@arunbagul:~# ls -l && pwd
      total 48
      drwxr-xr-x 2 root root 4096 2006-02-25 05:19 Desktop
      drwxr-xr-x 2 root root 4096 2006-02-25 05:19 Documents
      drwxr-xr-x 2 root root 4096 2006-02-25 05:19 Music

      /root

      root@arunbagul:~#

      root@arunbagul:~# ls -M && pwd
      ls: invalid option — M
      Try `ls –help’ for more information.
      root@arunbagul:~#

      command (1) run-parts – is the command which runs all the executable files , script or programs in given directory!.

      –test print the names of the scripts which would be run, but don’t actually run them.

      –list print the names of the all matching files (not limited to executables), but don’t actually run them. This option cannot be used with –test.

      -v, –verbose
      print the name of each script to stderr before running.

      –report
      similar to –verbose, but only prints the name of scripts which produce output. The script’s name is printed to whichever of stdout or
      stderr the script first produces output on.

      –reverse
      reverse the scripts’ execution order.

      –exit-on-error
      exit as soon as a script returns with a non-zero exit code.

      Now we will see what this command is doing …

      root@arunbagul:~# run-parts –list /etc/cron.hourly/
      /etc/cron.hourly/arun
      /etc/cron.hourly/autocommit
      /etc/cron.hourly/backup
      /etc/cron.hourly/download
      /etc/cron.hourly/ftp
      root@arunbagul:~#

      so all above script will be run by crontab hourly. –list option will list the script which would be run by crontab hourly and –report option will run the all scripts within given directory…

      * This is how hourly schedule jobs are executed/run by cron tab.

      b) Daily, Weekly and Hourly crontabs –

      Setting for daily, weekly and monthly crontabs is defined in /etc/crontab file. Now we will see 5th, 6th and 7th line of /etc/crontab file…

      25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
      47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly )
      52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )

      * crontab (cron daemon) will execute/run the script “test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )” at 6:25 AM on every day, as this is daily job.

      *cron will run this script “test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly )” at 6:47 AM on every sunday as this is weekly job.

      * cron will run this script “test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )” at 6:52 AM on 1st day of every month as this is monthly job.

      Now we will see what is this command doing – “||” operator is act as logical OR, means if first script is successful then second script would not be executed or run. and vice versa. let’s see one example here….

      root@arunbagul:~# ll || pwd
      total 48
      drwxr-xr-x 2 root root 4096 2008-04-03 23:23 Desktop
      drwxr-xr-x 2 root root 4096 2006-02-25 05:19 Documents
      -rwxr-x— 1 root root 266 2008-02-15 09:48 myscript.sh

      root@arunbagul:~#

      root@arunbagul:~# ll -M || pwd
      ls: invalid option — M
      Try `ls –help’ for more information.

      /root

      root@arunbagul:~#

      ** Now we will check first part of command ie “test -x /usr/sbin/anacron“. ‘test‘ is the command which is used to check ‘file’ types and compare values. Here “-x” options check whether file exist or not and is file executalble (executable permission) or not?.. see below

      root@arunbagul:~# test -x /usr/sbin/anacron
      root@arunbagul:~#

      root@arunbagul:~# echo $?
      0
      root@arunbagul:~#

      So “/usr/sbin/anacron” file exist and it is executable that’s why command is successful so second part of command ie “( cd / && run-parts –report /etc/cron.weekly )” will NOT be executed as first part of command is successfully executed!

      root@arunbagul:~# run-parts –list /etc/cron.weekly
      /etc/cron.weekly/0anacron
      /etc/cron.weekly/man-db
      /etc/cron.weekly/popularity-contest
      /etc/cron.weekly/sysklogd
      root@arunbagul:~#

      root@arunbagul:~# run-parts –test /etc/cron.weekly
      /etc/cron.weekly/0anacron
      /etc/cron.weekly/man-db
      /etc/cron.weekly/popularity-contest
      /etc/cron.weekly/sysklogd
      root@arunbagul:~#

      command (2) anacron – runs commands periodically. Anacron can be used to execute commands periodically, with a frequency specified in days. Unlike cron, it does not assume that the machine is running continuously. Hence, it can be used on machines that aren’t running 24 hours a day and to control daily, weekly, and monthly jobs that are usually controlled by cron.

      When executed, Anacron reads a list of jobs from a configuration file, normally “/etc/anacrontab“. This file contains the list of jobs that Anacron controls. Each job entry specifies a period in days, a delay in minutes, a unique job identifier, and a shell command. For each job, Anacron checks whether this job has been executed in the last n days, where n is the period specified for that job. If not, Anacron runs the job’s shell command, after waiting for the number of minutes specified as the delay parameter. After the command exits, Anacron records the date in a special timestamp file for that job, so it can know when to execute it again. Only the date is used for the time calculations. The hour is not used. When there are no more jobs to be run, Anacron exits. Anacron only considers jobs whose identifier, as specified in the anacrontab matches any of the job command-line arguments. The job arguments can be shell wildcard patterns (be sure to protect them from your shell with adequate quoting). Specifying no job arguments, is equivalent to specifying “*”.

      ** “/var/spool/anacron” is the spool directory used by Anacron for storing timestamp files.

      -f Force execution of the jobs, ignoring the timestamps.

      -u Only update the timestamps of the jobs, to the current date, but don’t run anything.

      -s Serialize execution of jobs. Anacron will not start a new job before the previous one finished.

      -n Run jobs now. Ignore the delay specifications in the /etc/anacrontab file. This options implies -s.

      -d Don’t fork to the background. In this mode, Anacron will output informational messages to standard error, as well as to syslog. The out‐
      put of jobs is mailed as usual.

      -q Suppress messages to standard error. Only applicable with -d.

      ** Check what is there in /etc/anacrontab file –

      root@arunbagul:~# cat /etc/anacrontab
      SHELL=/bin/sh
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

      # These replace cron’s entries
      1 5 cron.daily nice run-parts –report /etc/cron.daily
      7 10 cron.weekly nice run-parts –report /etc/cron.weekly
      @monthly 15 cron.monthly nice run-parts –report /etc/cron.monthly

      root@arunbagul:~#

      The format of “/etc/anacrontab” file is ..

      Field No Field
      ——– —————-
      (1) Period in days
      (2) Delay in minutes
      (3) Unique job identifier
      (4) Shell command

      * Daily – The period is 1 day , delay is 5 min and command is “nice run-parts –report /etc/cron.daily”.
      * Weekly – The period is 7 days , 10 min delay time and command is “nice run-parts –report /etc/cron.weekly”
      * Monthly – The period is one month and 15 min as delay time

      Please read the man page of ‘nice’ command and we know what this “run-parts” command is doing…

      root@arunbagul:~# run-parts –list /etc/cron.weekly
      /etc/cron.weekly/0anacron
      /etc/cron.weekly/man-db
      /etc/cron.weekly/popularity-contest
      /etc/cron.weekly/sysklogd
      root@arunbagul:~#

      root@arunbagul:~# run-parts –test /etc/cron.weekly
      /etc/cron.weekly/0anacron
      /etc/cron.weekly/man-db
      /etc/cron.weekly/popularity-contest
      /etc/cron.weekly/sysklogd
      root@arunbagul:~#

      root@arunbagul:~# run-parts –list /etc/cron.monthly/
      /etc/cron.monthly//0anacron
      /etc/cron.monthly//proftpd
      /etc/cron.monthly//scrollkeeper
      /etc/cron.monthly//standard
      root@arunbagul:~#

      root@arunbagul:~# run-parts –test /etc/cron.monthly/
      /etc/cron.monthly//0anacron
      /etc/cron.monthly//proftpd
      /etc/cron.monthly//scrollkeeper
      /etc/cron.monthly//standard
      root@arunbagul:~#

      ** Check what is there in spool directory “/var/spool/anacron/” –

      root@arunbagul:~# cd /var/spool/anacron/
      root@arunbagul:/var/spool/anacron# ll
      total 12
      -rw——- 1 root root 9 2008-04-03 23:35 cron.daily
      -rw——- 1 root root 9 2008-03-13 14:32 cron.monthly
      -rw——- 1 root root 9 2008-04-04 00:19 cron.weekly
      root@arunbagul:/var/spool/anacron#

      root@arunbagul:/var/spool/anacron# cat cron.daily
      20080403
      root@arunbagul:/var/spool/anacron#

      root@arunbagul:/var/spool/anacron# cat cron.monthly
      20080313
      root@arunbagul:/var/spool/anacron#

      root@arunbagul:/var/spool/anacron# cat cron.weekly
      20080404
      root@arunbagul:/var/spool/anacron#

      Summary of article –

      Scheduling in GNU/Linux or Unix is achieved by crontab (cron daemon) with the help of anacron and run-parts commands!

      Thank you,

      Arun Bagul

      How to schedule job in Linux/Unix – cron , crontab

      How to schedule job in Linux/Unix – cron , crontab

      Introduction – cron is a daemon to execute scheduled commands on Linux and UNIX operating system.There are two type of cron job (crontab) –

      1) User based cron job (crontab)
      2) System wide cron job (crontab)

      1] User based cron job (crontab) –

      ‘crontab’ command is used to schedule user based cron jobs. Each user has their own crontab and cron jobs will be executed as the user who owns the crontab.

      Cron daemon automatically sets several environment variables like SHELL is set to /bin/sh, and LOGNAME or USER and HOME are set from the /etc/passwd line of the crontab’s owner. PATH is set to “/usr/bin:/bin”. But user can change HOME, SHELL, and PATH in his the crontab; LOGNAME or USER is the user that the job is running from, and may not be changed….

      In addition cron daemon will also check system/environment variable MAILTO for sending mail as a result of running commands. If MAILTO is defined (and non-empty) then mail is sent to the user. If MAILTO is defined but empty (MAILTO=””), no mail will be sent. Otherwise mail is sent to the owner of the crontab.

      root@arunbagul:~# echo $MAILTO

      root@arunbagul:~#

      * How to set MAILTO variable-

      arun@arunbagul:~$ crontab -l

      MAILTO=”arunbagul@indiangnu.org,indiangnu@yahoo.com”
      PATH=”/bin:/sbin/:/usr/bin”
      SHELL=/bin/bash

      arun@arunbagul:~$

      The system/environment EDITOR also used by cron daemon. this variable defaine the deafult editor which is used by crontab for editing the crontab file or cron job scheduling…

      arun@arunbagul:~$ echo $EDITOR

      arun@arunbagul:~$

      arun@arunbagul:~$ export EDITOR=pico
      arun@arunbagul:~$ echo $EDITOR
      pico
      arun@arunbagul:~$

      If you want to change the default editor for any user then add this line “export EDITOR=pico” to profile files of that user(.bashrc , .bash_profile or .profile). Cron also supports the pam_env module, and loads the environment specified by /etc/security/pam_env.conf. But PAM setting do NOT override the settings described above or any settings in the crontab file itself.

      root@arunbagul:~# crontab
      crontab: usage error: file name must be specified for replace
      usage: crontab [-u user] file
      crontab [-u user] { -e | -l | -r }
      (default operation is replace, per 1003.2)
      -e (edit user’s crontab)
      -l (list user’s crontab)
      -r (delete user’s crontab)
      root@arunbagul:~#

      1) How to list crontab or cron job –

      To list the crontab/cron job use below command..

      arun@arunbagul:~$ crontab -l

      * * * * * /home/arun/mycron.sh
      arun@arunbagul:~$

      root@arunbagul:~# crontab -l -u arun

      * * * * * /home/arun/mycron.sh
      root@arunbagul:~#

      ** -u <user name> options is used to list crontab for particular user…

      2) How to schedule (edit) crontab or cron job –

      ** -e -u <user name> option is used to edit the cron tab file for user mentioned with -u options

      root@arunbagul:~# crontab -u arun -e
      No modification made
      root@arunbagul:~# crontab -u arun -e
      crontab: installing new crontab
      root@arunbagul:~#

      arun@arunbagul:~$ crontab -u arun -e
      crontab: installing new crontab
      arun@arunbagul:~$

      3) How to delete user’s cron job –

      ** -r -u <user name> option is used to delete the crontab for user mentioned with -u option

      arun@arunbagul:~$ crontab -u arun -l

      1 * * * * /home/arun/update.sh 2>&1 /home/arun/update.log
      * * * * * /home/arun/mycron.sh

      arun@arunbagul:~$

      arun@arunbagul:~$ crontab -u arun -r
      arun@arunbagul:~$

      arun@arunbagul:~$ crontab -u arun -l
      no crontab for arun
      arun@arunbagul:~$

      4) Format of crontab file –

      Active line in a crontab will be either an environment setting or a cron command. An environment setting is of the form,
      name = value

      where the spaces around the equal-sign (=) are optional.

      crontab file has six columns/fields and each line is consider as one cron job/command (row), except environment setting line whose format is like “name = value”. The first five columns/fields are time and date column/fields by which user can schedule the job. The six column/field is command. The fields may be separated by spaces or tabs. The time and date fields are….

      Field No Field Allowed values
      ————- ————- —————————-
      (1) Minute 0-59
      (2) Hour 0-23
      (3) Day of Month 1-31
      (4) Month 1-12 (or names, see below)
      (5) Day of Week 0-7 (0 or 7 is Sunday, or use names)

      * Names can also be used for the “Month” and “Day of Week” fields. Use the first three letters of the particular day or month (case doesn’t matter).

      Months Name used in cronjob – jan, feb ,mar, apr, may, jun, jul, aug, sep, oct, nov and dec.
      Day of the Week – sun, mon, tue, wed, thu, fri and sat

      Field (6) – The “sixth field” (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless
      escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. There is no way to split a single command line onto multiple lines, like the shell’s trailing “\”.

      Note:- If both fields ‘Day of Month‘ and ‘Day of week‘ are specified (i.e. they are not *), then the command will be run when either field matches the current time.

      For example…

      arun@arunbagul:~$ crontab -l -u arun

      30 6 1,7,14,21,28 * 5 /home/arun/weekly.sh > /home/arun/weekly.log

      arun@arunbagul:~$

      * The above cron job will be executed at 6:30 am on the 1st, 7th,14th, 21st and 28th day of each month (and)plus every Friday.

      5) Different types of filed format –

      * cron daemon examines cron entries once every minute.
      * A field may be an asterisk (*), which always stands for ‘first-last‘.
      * Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 7-11 for an ‘hours’ entry specifies execution at hours 7, 8, 9, 10 and 11.

      * Lists are allowed. A list is a set of numbers (or ranges) separated by commas. For examples: “1,2,5,9”, “0-4,8-12”.

      * Step values can be used with ranges. Following a range with “/<number>” specifies skips of the number’s value through the range.
      For example, “0-23/2” can be used in the hours field to specify command execution every other hour. Steps are also permitted after an asterisk(*), so if you want to say “every three hours“, just use “*/3“.

      * Ranges or lists of names are not allowed.

      ** Instead of the first five fields, one of eight special strings may be used….

      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 * * * *”.

      6) Examples of crontab –

      root@arunbagul:~# crontab -l

      #run command at midnight, every day
      0 0 * * * /root/bin/daily.job >> /tmp/daily.log 2>&1

      # run at 3:40pm on the first of every month
      40 14 1 * * /root/bin/monthly.log > /dev/null 2> /var/log/monthly.error

      # Send birth day mail to your friend
      1 0 17 jan * mail -s “Hi!! Ravi,” Wish you%HAPPY BIRTH DAY!!%%your friend%%Arun%

      root@arunbagul:~#

      2] System wide cron job (crontab) –

      System wide setting for cron is defined in file /etc/crontab and /etc/cron.d directory. This file is slightly different from crotab(user based) file. This file has seven field/column. First five fields are same as crontab(user based) file. 6th field is the User Name, who is the owner of cron job scheduled to run and 7th field is actually 6th field of crontab(user based).

      root@arunbagul:~# cat /etc/crontab
      SHELL=/bin/sh
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

      # m h dom mon dow user command
      17  *  *  *  *     root cd / && run-parts –report /etc/cron.hourly
      25  6 *  *   *    root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
      47  6   *  *  7   root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly )
      52   6  1  *  *  root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )
      #

      root@arunbagul:~#

      ** Unlike any other crontab you don’t have to run the ‘crontab’ command to modify the “/etc/crontab” file and files in /etc/cron.d directory. These files also have user name fields, that none of the other crontabs do.

      For example…

      root@arunbagul:/etc/cron.d# pwd
      /etc/cron.d
      root@arunbagul:/etc/cron.d# ls
      anacron php5
      root@arunbagul:/etc/cron.d# cat anacron
      # /etc/cron.d/anacron: crontab entries for the anacron package

      SHELL=/bin/sh
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

      30 7 * * * root test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null
      root@arunbagul:/etc/cron.d#

      Now check the “/etc/crontab” file. There are several cron jobs entry…..

      a) Hourly cron job –

      In /etc/crontab the first cron job entry is for hourly process. All the files (crontab files) in directory /etc/cron.hourly/ will be
      kick off at 17min of every hour.
      For example

      root@arunbagul:/etc/cron.hourly# pwd
      /etc/cron.hourly
      root@arunbagul:/etc/cron.hourly# ls
      mail_filter_from_arun.sh
      root@arunbagul:/etc/cron.hourly#

      b) Daily cron job –

      The 2nd cron entry in /etc/crontab file is for daily job scheduling. All the files (crontab files) in directory /etc/cron.daily/ will be
      kick off at 06:25am daily. For example…

      root@arunbagul:/etc/cron.daily# pwd
      /etc/cron.daily
      root@arunbagul:/etc/cron.daily# ls
      0anacron   apport  aptitude   exim4-base   find.notslocate.dpkg-new   man-db  quota  standard
      apache2    apt   bsdmainutils   find.notslocate   logrotate   perlindex    slocate    sysklogd

      root@arunbagul:/etc/cron.daily#
      root@arunbagul:/etc/cron.daily# cat logrotate
      #!/bin/sh

      test -x /usr/sbin/logrotate || exit 0
      /usr/sbin/logrotate /etc/logrotate.conf
      root@arunbagul:/etc/cron.daily#

      c) Weekly cron job –

      The 3rd entry in /etc/crontab file is for weekly job scheduling. All the files (crontab files) in directory /etc/cron.weekly/ will be
      kick off at 06:47am every sunday. For example…

      root@arunbagul:/etc/cron.weekly# pwd
      /etc/cron.weekly
      root@arunbagul:/etc/cron.weekly# ls
      0anacron man-db popularity-contest sysklogd
      root@arunbagul:/etc/cron.weekly#

      root@arunbagul:/etc/cron.weekly# cat 0anacron
      #!/bin/sh
      #
      # anacron’s cron script
      #
      # This script updates anacron time stamps. It is called through run-parts
      # either by anacron itself or by cron.
      #
      # The script is called “0anacron” to assure that it will be executed
      # _before_ all other scripts.

      test -x /usr/sbin/anacron || exit 0
      anacron -u cron.weekly
      root@arunbagul:/etc/cron.weekly#

      d) Monthly cron job –

      The 4rd entry in /etc/crontab file is for monthly job scheduling. All the files (crontab files) in directory /etc/cron.monthly/ will be
      kick off at 06:52am on 1st Day of every month. For example….

      root@arunbagul:/etc/cron.monthly# pwd
      /etc/cron.monthly
      root@arunbagul:/etc/cron.monthly# ls
      0anacron proftpd scrollkeeper standard
      root@arunbagul:/etc/cron.monthly#

      root@arunbagul:/etc/cron.monthly# cat proftpd
      #!/bin/sh
      #
      # cron script to rotate the proftpd server logfile, based on the
      # wu-ftpd script by Peter Tobias <tobias@et-inf.fho-emden.de>.

      [ -x /usr/sbin/ftpstats ] || exit 0

      cd /var/log/proftpd
      savelog -q -u root -g adm -m 640 -c 12 /var/log/proftpd/xferreport
      ftpstats -a -r -l 2 -d 2>/dev/null >/var/log/proftpd/xferreport
      savelog -q -u root -g adm -m 640 -c 7 /var/log/proftpd/xferlog
      savelog -q -u root -g adm -m 640 -c 7 /var/log/proftpd/proftpd.log
      savelog -q -u root -g adm -m 640 -c 7 /var/log/proftpd/controls.log
      root@arunbagul:/etc/cron.monthly#

      ** Now It’s clear to all how to schedule job in Linux/Unix operating system by using cron daemon.

      Thank you,
      Arun Bagul

      How to disabled/enabled access to crontab?

      How to disabled/enabled access to crontab?

      Introduction – Some one ask me, Is there any way disabled or enabled access to crontab? I replied with answer Yes, there is way to manage access to crontab!!. But Why we need to restrict some one from setting/accessing crontab? Any system/Linux/Unix Admin wants that, only Admin should have full access to System and they should restrict every other users from accessing the Systems fully!! Anyway Let’s see How to do it?

      crontab can control/manage access to crontab by using “/etc/cron.allow” and “/etc/cron.deny” files. If /etc/cron.allow file exists, then USER must be listed in this file, in order to allowed to use this command. If the /etc/cron.allow file does not exist but the /etc/cron.deny file does exist, then USER must not be listed in the /etc/cron.deny file in order to use this command. If neither of these files exists then the access to crontab is depends on operating system. If both /etc/cron.allow and /etc/cron.deny files exist, then USER listed in /etc/cron.allow will be allowed to access crontab irrespective of entry in /etc/cron.deny and USER , who are listed in /etc/cron.deny file, will NOT be allowed to access crontab if that USER is not listed in /etc/cron.allow file!

      NOTE – By default “/etc/cron.allow” and “/etc/cron.deny” files does not exist on the system. The System Admin can create these files for customizing the System!!

      Step(1) Create these two files /etc/cron.allow and /etc/cron.deny on your system – remember you can create both file or any of these two files for managing the access to crontab. It’s depends upon your policy.

      root@arunbagul:~# touch /etc/cron.allow /etc/cron.deny
      root@arunbagul:~#

      Step(2) Make sure that all system users are not allow to use crontab command. As they all are listed in “/etc/cron.deny” file.

      root@arunbagul:~# cat /etc/cron.deny
      daemon bin sys sync games man lp mail news uucp proxy
      www-data backup list irc gnats nobody dhcp syslog klog messagebus hplip
      avahi-autoipd avahi haldaemon gdm mysql Debian-exim proftpd ftp subversion
      jabber sshd bind zabbix statd ntop
      root@arunbagul:~#

      Step(3) Check what is there in “/etc/cron.allow” file –

      root@arunbagul:~# cat /etc/cron.allow

      root@arunbagul:~#

      Step(4) Who am I? and Do I have access to crontab ? –

      I am logged in as normal user = ‘arun’

      arun@arunbagul:/$ who am i
      arun pts/1 2007-04-08 15:25 (:0.0)
      arun@arunbagul:/$

      arun@arunbagul:/$ crontab -l
      You (arun) are not allowed to use this program (crontab)
      See crontab(1) for more information
      arun@arunbagul:/$

      arun@arunbagul:/$ crontab -l -u arun
      You (arun) are not allowed to use this program (crontab)
      See crontab(1) for more information
      arun@arunbagul:/$

      arun@arunbagul:/$ crontab -e -u arun
      You (arun) are not allowed to use this program (crontab)
      See crontab(1) for more information
      arun@arunbagul:/$

      Ooh my god, I can’t use crontab command at all, even I can’t list my crontab. So no question of editing crontab….

      Now let’s check whether ‘arun’ user is listed in /etc/cron.deny file or not?

      arun@arunbagul:/$ cat /etc/cron.deny | grep “arun”
      arun@arunbagul:/$

      Oops, user ‘arun‘ is not listed in /etc/cron.deny. Now check whether ‘/etc/cron.allow‘ file exit or not?

      NOTE – ‘root’ user has full access crontab command, irrespective of entry in any of /etc/cron.allow and /etc/cron.deny files.

      root@arunbagul:~# crontab -l
      # m h dom mon dow command
      * * * * * /root/update.sh
      * * * * 7 /root/weekly.update
      root@arunbagul:~#

      arun@arunbagul:/$ cat /etc/cron.allow

      arun@arunbagul:/$

      It’s there? – I have no way to request my System/Linux Admin to add my name in /etc/cron.allow file to access the crontab? In this case I am the Admin!! so I will add ‘arun’ user in /etc/cron.allow file. done!!

      root@arunbagul:~# cat /etc/cron.allow
      arun
      ravi
      nishit
      root@arunbagul:~#

      * I have added few users in /etc/cron.allow file. So that they can access crontab command. so user ‘arun‘ can access crontab command.. check Now!

      arun@arunbagul:/$ crontab -l
      # m h dom mon dow command
      */3 * * * * /home/arun/download_mail.sh
      * 0 * * * /home/arun/update.sh
      arun@arunbagul:/$

      arun@arunbagul:/$ crontab -l -u arun
      # m h dom mon dow command
      */3 * * * * /home/arun/download_mail.sh
      * 0 * * * /home/arun/update.sh
      arun@arunbagul:/$

      I can EDIT my crontab –

      arun@arunbagul:/$ crontab -e -u arun
      crontab: installing new crontab
      arun@arunbagul:/$

      arun@arunbagul:/$ crontab -l -u arun
      # m h dom mon dow command
      */3 * * * * /home/arun/download_mail.sh
      * 0 * * * /home/arun/update.sh
      * * * * 7 /home/arun/weekly_update.sh
      arun@arunbagul:/$

      Thank you,
      Arun Bagul