1. What
is Job scheduling?
The
process of creating the jobs and make them occur on the system repeatedly
hourly, daily, weekly, monthly and
yearly is called Job scheduling. In Linux and other Unix systems this process
is handled by the cron service or deamon
called crondand
atd is the at jobs
deamon which can be used to schedule the
tasks (also called as jobs).
2. What
is the importance of the job scheduling?
The
importance of the job scheduling is that the critical tasks like backups, which
the client usually wants to be taken
in nights, can easily performed without the intervention of the administrator
by scheduling a cron job. If the
cron job is scheduled carefully then the backup
will be taken at any given time of the client and there will be no need for the administrator to remain
back at nights to take the backup.
3. What
are the differences between cron and
at jobs?
cron
job :
(i) cron
jobs are scheduling jobs automatically at a particular time, day of the
week, week of the month and month of the year.
(ii) The job may be a file or
file system.
(iii) We cannot get the information as a log
file if the job was failed to execute ie., when it was failed and where is
was failed and also cannot execute automatically the failed jobs.
at job :
(i) at
jobs are executes only once.
(ii) Here also we cannot get the
information if the job is failed and it is also do not execute the failed jobs automatically.
4. What
are the important files related to cron and at jobs?
/etc/crontab ----->
is the file which stores all the scheduled jobs.
/etc/cron.deny ----->
is the file used to restrict the users from using cron jobs.
/etc/cron.allow
-----> is
used to allow only users whose names are mentioned in this file to use cron
jobs and this file does not exist by default.
/etc/at.deny ----->same as cron.deny for restricting
the users to use at jobs.
/etc/at.allow ----->
same as cron.allow for allowing users to use at jobs.
5. What
is the format of the cron job?
#
crontab -e (to edit the
cron job editor to create or remove the cron jobs)
(0
- 59) (0 - 23) (1
- 31) (1 - 12 or jan, feb, ...) (0 - 6 or sun, mon, ...)
Options
|
Explanation
|
*
|
Is treated as a wild card. Meaning any possible
value.
|
*/ 5
|
Is treated as ever 5 minutes, hours, days or
months. Replacing he 5 with any
numerical value will change this option.
|
2, 4, 6
|
Treated as an OR, so if placed in the hours, this
could mean at 2, 4 or 6 o-clock
|
9-17
|
Treats for any value between 9
and 17. So if placed in day of
the month this would be days 9 through
17 or if put in hours, it would
be between 9 AM and
5 PM.
|
6. How
to check the assigned cron jobs of currently login user?
#
crontab -l -u (to
check the specified user's assigned cron
jobs)
#
crontab -l -u
raju (to
check the raju user's assigned cron jobs)
#
crontab -l (to
check the root user's assigned cron
jobs)
7. How
to allow or deny cron jobs for a user?
For allow
|
For deny
|
(i)
Open /etc/cron.allow file.
|
(i)
Open /etc/cron.deny file.
|
(ii) Put
the entries of the user names whom do we
want
to allow the cron jobs.
|
(ii) Put
the entries of the user names whom do we
want
to deny the cron jobs.
|
8. What is at
job and
atq source?
(i) at
jobs are executes only once.
(ii) atq
means how many at jobs are in queue by # atq
command.
9. How to
check the jobs?
#
at -l (to
check the at jobs)
10. How to
add crontab entry in command mode?
(i) # define editor=vim (to
define the editor as vim)
(ii) # export $editor (export
the defined editor)
(iii) # crontab -e (to
edit the crontab)
11. How to
troubleshoot if the cron job failed?
(i) See the crontab entries for
syntactical errors. If there are any errors then correct them, otherwise it
will not execute.
(ii) Check whether the crond deamon is working or not. If it is running, then
stop the deamon and again start the deamon. Even though the
problem occurs, then the crontab entries may be wrong.
(iii) If all the above are ok, then see whether the user who
executing cron job has permissions to execute the cron jobs
or not ie., check the user
entries in /etc/cron.allow and
/etc/cron.deny files.
(iv) If all are ok, again put the job entry in crontab and
execute it.
12. How to
schedule the cron task or job?
(i) Open one shell script file.
(ii) Enter all the commands which are
required to complete the task or job.
(iii) If the job requires more CPU
and more memory, then schedule
those jobs at night time or non-peak hours (generally night time is the
non-peak time).
(iv)
Then open crontab editor by
# crontab -e
command
and then put the entries as below,
No comments:
Post a Comment