How to make a Linux Scheduling with Crontabs – (Part-3)

0

Dear Viewers,

Today we are discuss setting up a user-level crontab of linux platform. Its important our professional sector. So, buildup your idea………………..

PART-1

PART-2

Setting Up A User-level crontab

Setting up a user-level crontab is somewhat different. The files in /var/spool/cron are not edited directly. Instead, a program called “crontab” is used to manipulate them. Depending on system security, all users, only some, or just the root user will be able to use crontab (see /etc/cron.allw and /etc/cron.deny later for more).

SYSNOPSIS crontab [-u user ] file

                     crontab [ -u user ] { -l | -r | -e }

file store the specified file as the current crontab

-u      user the crontab file being manipulated is for

-l        display the current crontab

-r       remove current  crontab

-e       edit the current crontab editor [vi]

Creating / Editing a User crontab

Step 01:

1)      Login as user ‘joy’ and do the following to create / edit an existing crontab for yourself.

         $crontab  -e

2)      Root can edit ‘joys’ crontab with:

         #crontab  -u  joy  -e

Step02:

1)      Login as user ‘joy’ and do the following to create file for yourself.

         $vi joy.ct and the enter your crontab details

         Crontab  -u  joy  joy.ct would be used to store the crontab for the user joy.

         $crontab  -e   To edit the crontab the next time and everytime.

Deleting A User crontab

1)      Login as user ‘joy’ and do the following to delete your crontab

         $crontab  -r  to and this will remove  /var/spool/cron/joy crontab file

2)      Root can delete joy’s crontab with:

          #crontab  -u  joy  -r

Listing A User crontab

1)      Login as user ‘joy’ and do the following to delete your crontab

         $crontab –l will show contents of /var/spool/cron/joy crontab file

2)      Root can list joy’s crontab with:

          #crontab –u joy –l

More Exercise:

A)       Login as user ‘joy’

           $crontab  -e

B)      Enter the following line and save the file

          * * * *  echo “Hello TechNews365”

          $crontab  -l  to see it’s contents

C)      After about 3 mins check you mail with the ‘mail’ command. You should have a mail every minute.

          Starting and Stopping the crond daemon

D)     To start, stop the cron service, use the command:

         # service crond start | stop

NB:

1)      It is recommended that you start the service at boot time. Use serviceconf, ntsysv or chkconfig to do this.

2)     Since crond anyway keeps checkin up on all crontab modtimes every minute, this action may be considered unnecessary.

                                                                                                      Stay with us ——————- Thanks Everyone

Share.

About Author

TN365

Leave A Reply

Powered by themekiller.com