AT
We use AT for one-shot jobs.
Syntax,
at time
atq [user]
atrm [user | at job ID]
Examples,
[root@localhost root]# at noon
[root@localhost root]# at now+10 minutes
[root@localhost root]# at 2320
[root@localhost root]# at 8:00pm December 7
[root@localhost root]# at 7 am Thursday
[root@localhost root]# at midnight+23 minutes
at> ls /root
at>
job 3 at 2005-11-25 23:20
Can't open /var/run/atd.pid to signal atd. No atd running?
ð Then you will get a command prompt of AT. Press Ctrl+D after you have entered all the command (jobs) you want, at responds with the <> sign and then display a jobs number. To start or restart the "at" service. Give the command as,
[root@localhost root]# service atd start
Starting atd: [ OK ]
ð It starts the atd service to execute its jobs instructed by the use.
[root@localhost root]# atq
2 2005-11-26 12:00 a root
3 2005-11-25 23:20 a root
ð Display all the jobs of "at" service.
[root@localhost root]# atrm
ð Kill the "at" jobs.
Example,
[root@localhost root]# atrm 2
[root@localhost root]# atq
3 2005-11-25 23:20 a root
ð atrm command ends the job numbered 2 of at service.
All the users can't use this "at" schedule service. To give the permission to other users administrator should edit the file called "at.allow" to add users’ login id.
[root@localhost root]# vi /etc/at.allow
root
sumon
azgar
ð Write the users’ login id in this file to give permission to users for using "at" service.
[root@localhost root]# vi /etc/at.deny
sumon
roy
ð Write the uses’ login name in this file to deny users’ permission to use "at" service. Remember that if any user’s login name is written in both at.deny and at.allow files the user can’t use at service.
CRON - Using cron for regular scheduled jobs.
The cron mechanism allows processes to be invoked periodically. Users need not be logged on. cron jobs are listed in a crontab file. cron table files (crontabs) are stored in (/var/spool/cron).
We must edit and install our cron table file. cron table file can’t be edited directly.
· Edit the file and then install with crontab.
· Edit the file through crontab.
Syntax,
crontab [-u user] file
crontab [-l | -r | -e]
Option | Performance |
-e | Edit. |
-l | Display. |
-e | Deletes it. |
[root@localhost root]# crontab –e
30 23 25 11 * top
40 23 * * 4 cal
~
~
~
~
~
~
"/tmp/crontab.9871" 0L, 0C
ð Now, vi editor is opened and we can give the scheduling jobs which jobs we want to execute at any selected time. The text format must be as below,
Entry consists of five space – delimited fields following by a command line (one entry per line, no limit to line length).
Syntax,
* * * * * task
Field | Description | Rang |
First * | Minute | 0 - 59 |
Second * | Hour | 0 - 23 |
Fourth * | Day of month | 1 - 31 |
Fifth * | Month | 1 - 12 |
Sixth * | Day of week | 0 - 6 (0=Sunday) |
Task | Which job will execute | |
Note: Comment lines begin with #. |
Example,
05 01 * * * incrback.sh
[root@localhost root]# crontab –l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.10050 installed on Fri Nov 25 23:30:45 2005)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
30 23 25 11 * top
40 23 * * 4 cal
ð It shows all the jobs and job's ID. You can find all the information from the file, "crontab" in "/etc" directory.
[root@localhost root]# vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
To allow the users to use cron service, administrator can edit two files.
[root@localhost root]# vi /etc/cron.allow
root
sumon
azgar
ð Write the users’ login id in this file to give permission to users for using cron service.
[root@localhost root]# vi /etc/cron.deny
sumon
roy
ð Write the uses’ login name in this file to deny users’ permission to use cron service. Remember that if any user’s login name is written in both at.deny and at.allow files the user can’t use cron service.
ntsysv Command
We can start any service at the booting time by using ntsysv command.
[root@localhost root]# ntsysv
ntsysv 1.3.9 - (C) 2000-2001 Red Hat, Inc.
_______________________ Services _____________________
| |
| What services should be automatically started? |
| |
| [*] acpid |
| [ ] aep1000 |
| [ ] amanda |
| [ ] amd |
| [ ] anacron |
| [ ] apmd |
| [ ] atd |
| [*] autofs |
| |
| |
| | Ok | | Cancel | |
| |
| |
|____________________________________________________|
Press
ð It will display which services will start at the booting time. We can change the settings.
[root@localhost root]# ntsysv --level <>
Example,
[root@localhost root]# ntsysv --level 5
ð Now we can mention which run level setting will be displayed.
Chkconfig Command
We can also use chkconfig command to start any services on any specific level at booting time.
[root@localhost root]# chkconfig --list
yum 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mailman 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netdump 0:off 1:off 2:off 3:off 4:off 5:off 6:off
psacct 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mdmpd 0:off 1:off 2:on 3:off 4:on 5:off 6:off
cpuspeed 0:off 1:on 2:on 3:off 4:on 5:on 6:off
isdn 0:off 1:off 2:on 3:off 4:on 5:off 6:off
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
snmptrapd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mdmonitor 0:off 1:off 2:on 3:off 4:on 5:off 6:off
dovecot 0:off 1:off 2:off 3:off 4:off 5:off 6:off
pcmcia 0:off 1:off 2:on 3:on 4:on 5:on 6:off
dhcpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
wine 0:off 1:off 2:on 3:off 4:on 5:off 6:off
dc_client 0:off 1:off 2:off 3:off 4:off 5:off 6:off
atd 0:off 1:off 2:off 3:off 4:on 5:off 6:off
readahead_early 0:off 1:off 2:off 3:off 4:off 5:off 6:off
smartd 0:off 1:off 2:on 3:off 4:on 5:off 6:off
readahead 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfslock 0:off 1:off 2:off 3:off 4:on 5:off 6:off
anacron 0:off 1:off 2:on 3:off 4:on 5:off 6:off
rpcidmapd 0:on 1:off 2:off 3:off 4:off 5:off 6:on
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
postgresql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
crond 0:off 1:off 2:on 3:off 4:on 5:off 6:off
netfs 0:off 1:off 2:off 3:off 4:on 5:off 6:off
random 0:off 1:off 2:on 3:off 4:on 5:off 6:off
spamassassin 0:off 1:off 2:on 3:off 4:on 5:off 6:off
innd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
dc_server 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
syslog 0:off 1:off 2:on 3:off 4:on 5:off 6:off
saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netplugd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
dhcrelay 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ypxfrd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
amd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
smb 0:off 1:off 2:off 3:off 4:off 5:off 6:off
cups 0:off 1:off 2:on 3:off 4:on 5:off 6:off
messagebus 0:off 1:off 2:off 3:off 4:on 5:off 6:off
vncserver 0:off 1:off 2:off 3:off 4:off 5:off 6:off
aep1000 0:off 1:off 2:off 3:off 4:off 5:off 6:off
irqbalance 0:off 1:off 2:off 3:off 4:on 5:off 6:off
squid 0:off 1:off 2:off 3:off 4:off 5:off 6:off
snmpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
hpoj 0:off 1:off 2:on 3:off 4:on 5:on 6:off
rhnsd 0:off 1:off 2:off 3:off 4:on 5:off 6:off
xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
bcm5820 0:off 1:off 2:off 3:off 4:off 5:off 6:off
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
sendmail 0:off 1:off 2:on 3:off 4:on 5:off 6:off
network 0:off 1:off 2:on 3:off 4:on 5:off 6:off
ypserv 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rpcgssd 0:on 1:off 2:off 3:off 4:off 5:off 6:on
sshd 0:off 1:off 2:on 3:off 4:on 5:off 6:off
acpid 0:off 1:off 2:off 3:off 4:on 5:on 6:off
kudzu 0:off 1:off 2:off 3:off 4:on 5:off 6:off
tux 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rawdevices 0:off 1:off 2:off 3:off 4:on 5:off 6:off
microcode_ctl 0:off 1:off 2:off 3:off 4:on 5:off 6:off
irda 0:off 1:off 2:off 3:off 4:off 5:off 6:off
apmd 0:off 1:off 2:on 3:off 4:on 5:off 6:off
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rpcsvcgssd 0:on 1:off 2:off 3:off 4:off 5:off 6:on
autofs 0:off 1:off 2:off 3:off 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:off 4:on 5:off 6:off
vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
portmap 0:off 1:off 2:off 3:off 4:on 5:off 6:off
named 0:off 1:off 2:off 3:off 4:off 5:off 6:off
yppasswdd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
lisa 0:off 1:off 2:off 3:off 4:off 5:off 6:off
xinetd based services:
amanda: off
chargen: off
daytime-udp: off
rsync: off
chargen-udp: off
cups-lpd: off
time-udp: off
services: off
telnet: off
sgi_fam: off
echo-udp: off
echo: off
time: off
ktalk: off
daytime: off
ð It shows all the service's status for all run level.
[root@localhost root]# chkconfig --level 2345 xinetd on
[root@localhost root]# chkconfig --level 3 firstboot on
[root@localhost root]# chkconfig --list firstboot
firstboot 0:off 1:off 2:off 3:on 4:off 5:off 6:off
ð It shows the status of a specific service of all run levels.
[root@localhost root]# chkconfig --level 3 firstboot off
[root@localhost root]# chkconfig --list firstboot
firstboot 0:off 1:off 2:off 3:off 4:off 5:off 6:off
Service command
Another important command is service which command is used on the running time of system. We can start a specific service by this command. There are five options of this command as below.
start - To start a service.
restart - To restart a service.
stop - To stop a service.
status - To see the status of service.
reload - To restart the service.
[root@localhost root]# service httpd start
Starting httpd: [ OK ]
ð HTTP service will be start.
[root@localhost root]# service httpd status
httpd (pid 12817 12816 12815 12814 12813 12812 12811 12810 12807) is running...
ð It shows the status of HTTP.
[root@localhost root]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
ð HTTP service will be restart.
[root@localhost root]# service httpd stop
Stopping httpd: [ OK ]
ð HTTP server will stop.
Sometimes we may face some debug when we will go to restart the named service (or any other services). On that time we should use reload option to restart a service.
[root@localhost root]# service named reload
Reloading named: [ OK ]
ð It will restart the named server.