The Guru Of Tech - Gobind

Asterisk Insall, Codec Install, Vicidial Install.

Vicidial, Asterisk, Web-MeetMe, MySQL, OTRS

Vicidial, Asterisk, Web-MeetMe, MySQL, OTRS

Vicidial, Asterisk, Web-MeetMe, MySQL, OTRS

Vicidial, Asterisk, Web-MeetMe, MySQL, OTRS.

Vicidial, Asterisk, Web-MeetMe, MySQL, OTRS

Vicidial, Asterisk, Web-MeetMe, MySQL, OTRS.

Thursday, March 29, 2012

Asterisk Commands throught PHP script

<pre><table width="100%" style="border: 2px solid #CCCCCC;" cellpadding="3" cellspacing="3">
<tr bgcolor="#666666">
    <td align="center" background="stripe.png"><font color="#FFFFFF"><b><h1><?php system("hostname"); ?></h1></b></font></td>
  </tr>
  <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>Uptime:</b></font></td>
  </tr>
  <tr bgcolor="#FFE4E1">
    <td><?php system("uptime"); ?></td>
  </tr>
  <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>System Information:</b></font></td>
  </tr>
  <tr bgcolor="#FFDAB9">
    <td><?php system("uname -a"); ?></td>
  </tr>
 <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>Memory Usage (MB):</b></font></td>
  </tr>
  <tr bgcolor="#FFF0F5">
    <td><?php system("free -m"); ?></td>
  </tr>
 <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>Disk Usage:</b></font></td>
  </tr>
  <tr bgcolor="#E6E6FA">
    <td><?php system("df -h"); ?></td>
  </tr>
 <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>CPU Information:</b></font></td>
  </tr>
  <tr bgcolor="#F0FFF0">
    <td><?php system("cat /proc/cpuinfo | grep \"model name\\|processor\""); ?></td>
  </tr>
</table>

</pre>

Thursday, March 15, 2012

Configuration file for Asterisk SIP channels, for both inbound and outbound calls.

Asterisk as a SIP client
;***********For INBOUND Only*********************
register => 1001:password@mysipprovider.com/1234

;***********FOR INBOUND as well as OUTBOUND*********************
[SIPTRUNK]
fromuser=username or ip from where to send calls
host = remote-ip-address (where to send calls)
username=username
secret=any-passsword
fromdomain=remote-ip-address (Valid only when in [general] section or
type=peer.)
disallow=all
allow=g729
type = friend (user, peer, friend)
dtmfmode=rfc2833
dtmf=rfc2833
qualify = yes
rfc2833compensate=yes
insecure=port,invite
qualify = yes
canreinvite=no
restrictcid=yes
context = sip-call-in ( this section will be defined in
extensions.conf and If type=user, the Context for the inbound call
from this SIP user definition. If type=peer, the Context in the
dialplan for outbound calls from this SIP peer definition. If
type=friend the context used for both inbound and outbound calls
through the SIP entities definition. If no type=user entry matches an
inbound call, then a type=peer or type=friend will match if the
hostname or IP address defined in host= matches.)
In extensions.conf you'd then use a statement like this:.
;***********For OUTBOUND*********************
exten => _X.,1,Set(CDR(accountcode)=SIPTRUNK100)
exten => _X.,n,Dial(SIP/${EXTEN}@SIPTRUNK,60)
exten => h,n,Hangup()
;***********FOR INBOUND as well as OUTBOUND*********************
[sip-call-in]
exten => 1234,1,Answer ; 1234 is the contact extension, default
contact extension is "s"
exten => 1234,2,Dial(SIP/111,25,Ttr) ; incoming calls are redirected
to SIP telephone with number 111
exten => 1234,3,Hangup

Monday, March 12, 2012

Asterisk Detailed Variable List

Asterisk standard channel variables
There are a number of variables that are defined or read
by Asterisk. Here is a list of them. More information is
available in each application's help text. All these variables
are in UPPER CASE only.

to diaplay all channel variable use this command

DumpChan(<min_verbose_level>)

Variables marked with a * are builtin functions and can't be set,
only read in the dialplan. Writes to such variables are silently
ignored.

${ACCOUNTCODE} * Account code (if specified) (Deprecated; use ${CDR(accountcode)})
${BLINDTRANSFER} The name of the channel on the other side of a blind transfer
${BRIDGEPEER} Bridged peer
${CALLERANI} * Caller ANI (PRI channels) (Deprecated; use ${CALLERID(ani)})
${CALLERID} * Caller ID (Deprecated; use ${CALLERID(all)})
${CALLERIDNAME} * Caller ID Name only (Deprecated; use ${CALLERID(name)})
${CALLERIDNUM} * Caller ID Number only (Deprecated; use ${CALLERID(num)})
${CALLINGANI2} * Caller ANI2 (PRI channels)
${CALLINGPRES} * Caller ID presentation for incoming calls (PRI channels)
${CALLINGTNS} * Transit Network Selector (PRI channels)
${CALLINGTON} * Caller Type of Number (PRI channels)
${CHANNEL} * Current channel name
${CONTEXT} * Current context
${DATETIME} * Current date time in the format: DDMMYYYY-HH:MM:SS (Deprecated; use ${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)})
${DB_RESULT} Result value of DB_EXISTS() dial plan function
${DNID} * Dialed Number Identifier (Deprecated; use ${CALLERID(dnid)})
${EPOCH} * Current unix style epoch
${EXTEN} * Current extension
${ENV(VAR)} Environmental variable VAR
${GOTO_ON_BLINDXFR} Transfer to the specified context/extension/priority
after a blind transfer (use ^ characters in place of
| to separate context/extension/priority when setting
this variable from the dialplan)
${HANGUPCAUSE} * Asterisk cause of hangup (inbound/outbound)
${HINT} * Channel hints for this extension
${HINTNAME} * Suggested Caller*ID name for this extension
${INVALID_EXTEN} The invalid called extension (used in the "i" extension)
${LANGUAGE} * Current language (Deprecated; use ${LANGUAGE()})
${LEN(VAR)} * String length of VAR (integer)
${PRIORITY} * Current priority in the dialplan
${PRIREDIRECTREASON} Reason for redirect on PRI, if a call was directed
${RDNIS} * Redirected Dial Number ID Service (Deprecated; use ${CALLERID(rdnis)})
${TIMESTAMP} * Current date time in the format: YYYYMMDD-HHMMSS (Deprecated; use ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
${TRANSFER_CONTEXT} Context for transferred calls
${FORWARD_CONTEXT} Context for forwarded calls
${UNIQUEID} * Current call unique identifier
${SYSTEMNAME} * value of the systemname option of asterisk.conf

Application return values
In Asterisk 1.2, many applications return the result in a variable
instead of, as in Asterisk 1.0, changing the dial plan priority (+101).
For the various status values, see each application's help text.

${AGISTATUS} * agi()
${AQMSTATUS} * addqueuemember()
${AVAILSTATUS} * chanisavail()
${CHECKGROUPSTATUS} * checkgroup()
${CHECKMD5STATUS} * checkmd5()
${CPLAYBACKSTATUS} * controlplayback()
${DIALSTATUS} * dial() - see also ${HANGUPCAUSE}
${DBGETSTATUS} * dbget()
${ENUMSTATUS} * enumlookup()
${HASVMSTATUS} * hasnewvoicemail()
${LOOKUPBLSTATUS} * lookupblacklist()
${OSPAUTHSTATUS} * ospauth()
${OSPLOOKUPSTATUS} * osplookup()
${OSPNEXTSTATUS} * ospnext()
${OSPFINISHSTATUS} * ospfinish()
${PARKEDAT} * parkandannounce()
${PLAYBACKSTATUS} * playback()
${PQMSTATUS} * pausequeuemember()
${PRIVACYMGRSTATUS} * privacymanager()
${QUEUESTATUS} * queue()
${RQMSTATUS} * removequeuemember()
${SENDIMAGESTATUS} * sendimage()
${SENDTEXTSTATUS} * sendtext()
${SENDURLSTATUS} * sendurl()
${SYSTEMSTATUS} * system()
${TRANSFERSTATUS} * transfer()
${TXTCIDNAMESTATUS} * txtcidname()
${UPQMSTATUS} * unpausequeuemember()
${VMSTATUS} * voicmail()
${VMBOXEXISTSSTATUS} * vmboxexists()
${WAITSTATUS} * waitforsilence()


Various application variables
${CURL} * Resulting page content for curl()
${ENUM} * Result of application EnumLookup
${EXITCONTEXT} Context to exit to in IVR menu (app background())
or in the RetryDial() application
${MONITOR} * Set to "TRUE" if the channel is/has been monitored (app monitor())
${MONITOR_EXEC} Application to execute after monitoring a call
${MONITOR_EXEC_ARGS} Arguments to application
${MONITOR_FILENAME} File for monitoring (recording) calls in queue
${QUEUE_PRIO} Queue priority
${QUEUE_MAX_PENALTY} Maximum member penalty allowed to answer caller
${QUEUESTATUS} Status of the call, one of:
(TIMEOUT | FULL | JOINEMPTY | LEAVEEMPTY | JOINUNAVAIL | LEAVEUNAVAIL)
${RECORDED_FILE} * Recorded file in record()
${TALK_DETECTED} * Result from talkdetect()
${TOUCH_MONITOR} The filename base to use with Touch Monitor (auto record)
${TOUCH_MONITOR_FORMAT} The audio format to use with Touch Monitor (auto record)
${TOUCH_MONITOR_OUTPUT} * Recorded file from Touch Monitor (auto record)
${TXTCIDNAME} * Result of application TXTCIDName
${VPB_GETDTMF} chan_vpb

The MeetMe Conference Bridge uses the following variables:
${MEETME_RECORDINGFILE} Name of file for recording a conference with
the "r" option
${MEETME_RECORDINGFORMAT} Format of file to be recorded
${MEETME_EXIT_CONTEXT} Context for exit out of meetme meeting
${MEETME_AGI_BACKGROUND} AGI script for Meetme (zap only)
${MEETMESECS} * Number of seconds a user participated in a MeetMe conference

The VoiceMail() application uses the following variables:
${VM_CATEGORY} * Sets voicemail category
${VM_NAME} * Full name in voicemail
${VM_MAILBOX} * Mailbox Number
${VM_DUR} * Voicemail duration
${VM_MSGNUM} * Number of voicemail message in mailbox
${VM_CALLERID} * Voicemail Caller ID (Person leaving vm)
${VM_CIDNAME} * Voicemail Caller ID Name
${VM_CIDNUM} * Voicemail Caller ID Number
${VM_DATE} * Voicemail Date
${VM_MESSAGEFILE} * Path to message left by caller

The VMAuthenticate() application uses the following variables:
${AUTH_MAILBOX} * Authenticated mailbox
${AUTH_CONTEXT} * Authenticated mailbox context

DUNDiLookup() uses the following variables
${DUNDTECH} * The Technology of the result from a call to DUNDiLookup()
${DUNDDEST} * The Destination of the result from a call to DUNDiLookup()

The Zaptel channel sets the following variables:
${ANI2} * The ANI2 Code provided by the network on the incoming call. (ie, Code 29 identifies call as a Prison/Inmate Call) See also: NANPA ANI II Digits Assignments
${CALLTYPE} * Type of call (Speech, Digital, etc)
${CALLEDTON} * Dialplan for called number on PRI/BRI calls (17=international, 33=national, 65=local, 73=private, 0=unknown). Note: this is a misnomer, TON != dialplan.
${CALLINGSUBADDR} * Called PRI Subaddress
${FAXEXTEN} * The extension called before being redirected to "fax"
${PRIREDIRECTREASON} * Reason for redirect, if a call was directed
${SMDI_VM_TYPE} * When an call is received with an SMDI message, the 'type'
of message 'b' or 'u'

The SIP channel uses the following variables:
${SIPCALLID} * SIP Call-ID: header verbatim (for logging or CDR matching)
${SIPDOMAIN} * SIP destination domain of an inbound call (if appropriate)
${SIPUSERAGENT} * SIP user agent (THIS DOESNT WORK IN 1.8(+?), I DONT KNOW IF ANY OF THESE WORK EXCEPT FOR SIPURI)
${SIPURI} * SIP uri
${SIP_CODEC} Set the SIP codec for a call
${SIP_URI_OPTIONS} * additional options to add to the URI for an outgoing call
${RTPAUDIOQOS} RTCP QoS report for the audio of this call
${RTPVIDEOQOS} RTCP QoS report for the video of this call

The Agent channel uses the following variables:
${AGENTMAXLOGINTRIES} Set the maximum number of failed logins
${AGENTUPDATECDR} Whether to update the CDR record with Agent channel data
${AGENTGOODBYE} Sound file to use for "Good Bye" when agent logs out
${AGENTACKCALL} Whether the agent should acknowledge the incoming call
${AGENTAUTOLOGOFF} Auto logging off for an agent
${AGENTWRAPUPTIME} Setting the time for wrapup between incoming calls
${AGENTNUMBER} * Agent number (username) set at login
${AGENTSTATUS} * Status of login ( fail | on | off )
${AGENTEXTEN} * Extension for logged in agent

The Dial() application uses the following variables:
${DIALEDPEERNAME} * Dialed peer name
${DIALEDPEERNUMBER} * Dialed peer number
${DIALEDTIME} * Time for the call (seconds)
${ANSWEREDTIME} * Time from dial to answer (seconds)
${DIALSTATUS} * Status of the call, one of:
(CHANUNAVAIL | CONGESTION | BUSY | NOANSWER
| ANSWER | CANCEL | DONTCALL | TORTURE)
${DYNAMIC_FEATURES} * The list of features (from the applicationmap section of
features.conf) to activate during the call, with feature
names separated by '#' characters
${LIMIT_PLAYAUDIO_CALLER} Soundfile for call limits
${LIMIT_PLAYAUDIO_CALLEE} Soundfile for call limits
${LIMIT_WARNING_FILE} Soundfile for call limits
${LIMIT_TIMEOUT_FILE} Soundfile for call limits
${LIMIT_CONNECT_FILE} Soundfile for call limits
${OUTBOUND_GROUP} Default groups for peer channels (as in SetGroup)

    * See "show application dial" for more information


The chanisavail() application sets the following variables:
${AVAILCHAN} * the name of the available channel if one was found
${AVAILORIGCHAN} * the canonical channel name that was used to create the channel
${AVAILSTATUS} * Status of requested channel

When using macros in the dialplan, these variables are available
${MACRO_EXTEN} * The calling extensions
${MACRO_CONTEXT} * The calling context
${MACRO_PRIORITY} * The calling priority
${MACRO_OFFSET} Offset to add to priority at return from macro

The ChanSpy() application uses the following variables:
${SPYGROUP} * A ':' (colon) separated list of group names.
(To be set on spied on channel and matched against the g(grp) option)

If you compile with OSP support, these variables are used:
${OSPINHANDLE} OSP handle of in_bound call
${OSPINTIMELIMIT} Duration limit for in_bound call
${OSPOUTHANDLE} OSP handle of out_bound call
${OSPTECH} OSP technology
${OSPDEST} OSP destination
${OSPCALLING} OSP calling number
${OSPOUTTOKEN} OSP token to use for out_bound call
${OSPOUTTIMELIMIT} Duration limit for out_bound call
${OSPRESULTS} Number of remained destinations

Call File extension variables:
${REASON} The reason why an auto-dialout call failed




CDR Variables

If the channel has a cdr, that cdr record has it's own set of variables which
can be accessed just like channel variables. The following builtin variables
are available and, unless specified, read-only.

${CDR(clid)} Caller ID
${CDR(src)} Source
${CDR(dst)} Destination
${CDR(dcontext)} Destination context
${CDR(channel)} Channel name
${CDR(dstchannel)} Destination channel
${CDR(lastapp)} Last app executed
${CDR(lastdata)} Last app's arguments
${CDR(start)} Time the call started.
${CDR(answer)} Time the call was answered.
${CDR(end)} Time the call ended.
${CDR(duration)} Duration of the call.
${CDR(billsec)} Duration of the call once it was answered.
${CDR(disposition)} ANSWERED, NO ANSWER, BUSY
${CDR(amaflags)} DOCUMENTATION, BILL, IGNORE etc
${CDR(accountcode)} The channel's account code (read-write).
${CDR(uniqueid)} The channel's unique id.
${CDR(userfield)} The channels uses specified field (read-write).


In addition, you can set your own extra variables with a traditional
Set(CDR(var)=val) to anything you want.

NOTE Some CDR values (eg: duration & billsec) can't be accessed until the call has terminated. As of 91617, those values will be calculated on-demand if requested. Until that makes it into a stable release, you can set endbeforehexten=yes in cdr.conf, and then use the "hangup" context to wrap up your call.

Certain functional variables may be accessed with ${foo(<args>)}. A list
of these functional variables may be found by typing "show functions"
at the Asterisk CLI.

Saturday, March 3, 2012

Display Post Title Before Blog Title in Blogger for SEO

By default Blogger displays the blog title before post title. For an example <Blog Title>: <post title>.In terms of SEO this is bad. We want to display the post title first and then the blog title. To change the default behavior follow the following steps.
  • Log into Blogger and go the "Design" tab
  • Then click on "Edit HTML" link.
  • Make sure you take a back of your existing template by clicking on "Download Full Template" link and saving the XML file to a safe storage location.
  • Search for the following text in the template.

<title><data:blog.pageTitle/></title>
Then replace the above line in red with the following lines




<b:if cond='data:blog.pageType == &quot;item&quot;'>
<title><data:blog.pageName/> | <data:blog.title/></title>
<b:else/>
<title><data:blog.pageTitle/></title>
</b:if>

Finally save the change by clicking on "SAVE TEMPLATE" button and refresh your blog to see the results

Monday, February 27, 2012

How to continue processing a context after a Hangup

Asterisk Application ‘System()’ in h extension to
create callfile which will handle your callback.
You can also try for ‘Originate()’ application.

Example:

[Main]
exten => 111,1,Goto(cb,1,1)
exten => 222,1,Dial(SIP/666666)

[cb]
exten => 1,1,NoOp(Incoming call from # ${CALLERID(num)})
exten => 1,n,Goto(callback,333,1)

[callback]
;prepare for callback
exten => 333,1,NoOp(Hangup then callback to cellphone)
exten => 333,2,Hangup

exten => h,1,NoOp(copy callback.call file to /var/spool/asterisk/outgoing)
exten => h,n,System(echo -e "Channel: SIP/${CALLERID(num)}\\nContext: Main\\nExtension: 222" > /tmp/${UNIQUEID}.call)
exten => h,n,System(/bin/sleep 10s)
exten => h,n,System(mv /tmp/${UNIQUEID}.call /var/spool/asterisk/outgoing/)

OR

exten => 1,1,Wait(2)
exten => 1,n,Set(CID=${CALLERID(num)})
exten => 1,n,NoOp(Call from ${CID})
exten => 1,n,Hangup
exten => h,n,Originate(SIP/1001,app,Dial,SIP/1002)

Thursday, February 23, 2012

Asterisk Callback to the ANI and Dial another Call and Bridge them

Auto Callback to the ANI when ANI answers by the user, we Dial another Call and Bridge them

[Main]
exten => 111,1,Goto(cb,1,1)
exten => 222,1,Dial(SIP/666666)

[cb]
exten => 1,1,NoOp(Incoming call from # ${CALLERID(num)})
exten => 1,n,Goto(callback,333,1)

[callback]
;prepare for callback
exten => 333,1,NoOp(Hangup then callback to cellphone)
exten => 333,2,Hangup

exten => h,1,NoOp(copy callback.call file to /var/spool/asterisk/outgoing)
exten => h,n,System(echo -e "Channel: SIP/${CALLERID(num)}\\nContext: Main\\nExtension: 222" > /tmp/${UNIQUEID}.call)
exten => h,n,System(/bin/sleep 10s)
exten => h,n,System(mv /tmp/${UNIQUEID}.call /var/spool/asterisk/outgoing/)

Asterisk - Executing call files in the future

[Alarm-Algo]
exten => _*99*XXXXXXXXXXXX,1,Answer()
exten => _*99*XXXXXXXXXXXX,n,Set(year=${EXTEN:4:4})
exten => _*99*XXXXXXXXXXXX,n,Set(month=${EXTEN:8:2})
exten => _*99*XXXXXXXXXXXX,n,Set(day=${EXTEN:10:2})
exten => _*99*XXXXXXXXXXXX,n,Set(hours=${EXTEN:12:2})
exten => _*99*XXXXXXXXXXXX,n,Set(minutes=${EXTEN:14:2})
exten => _*99*XXXXXXXXXXXX,n,NoOp(Wake-up call scheduled for ${CALLERID(num)} at ${hours}:${minutes} on ${day}.${month}.${year}.)
exten => _*99*XXXXXXXXXXXX,n,System(echo -e "Channel: SIP/${CALLERID(num)}\\nContext: Alarm\\nExtension: 222" > /tmp/${UNIQUEID}.call)
exten => _*99*XXXXXXXXXXXX,n,System(touch -t ${year}${month}${day}${hours}${minutes} /tmp/${UNIQUEID}.call)
exten => _*99*XXXXXXXXXXXX,n,System(mv /tmp/${UNIQUEID}.call /var/spool/asterisk/outgoing/)
exten => _*99*XXXXXXXXXXXX,n,Playback(rqsted-wakeup-for)
exten => _*99*XXXXXXXXXXXX,n,SayNumber(${hours})
exten => _*99*XXXXXXXXXXXX,n,SayNumber(${minutes})
exten => _*99*XXXXXXXXXXXX,n,Hangup()

[Alarm]
exten => 222,1,Answer()
exten => 222,n,Wait(1)
exten => 222,n,Playback(this-is-your-wakeup-call)
exten => 222,n,Wait(1)
exten => 222,n,Hangup()

Saturday, February 18, 2012

Running Linux Commands through PHP

I have prepared a module that will show the CPU utilization, current processes, memory utilization and disk quota of a remote system when asked on a PHP page

Below is the syntax and code in PHP and HTML just copy and paste it on the desired directory.

<table width="900" border="0" cellpadding="3" cellspacing="3">
<tr bgcolor="#666666">
    <td align="center"><font color="#FFFFFF"><b><h1><?php system("hostname"); ?></h1></b></font></td>
  </tr>
  <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>Uptime:</b></font></td>
  </tr>
  <tr bgcolor="#FFE4E1">
    <td><?php system("uptime"); ?></td>
  </tr>
  <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>System Information:</b></font></td>
  </tr>
  <tr bgcolor="#FFDAB9">
    <td><?php system("uname -a"); ?></td>
  </tr>
 <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>Memory Usage (MB):</b></font></td>
  </tr>
  <tr bgcolor="#FFF0F5">
    <td><?php system("free -m"); ?></td>
  </tr>
 <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>Disk Usage:</b></font></td>
  </tr>
  <tr bgcolor="#E6E6FA">
    <td><?php system("df -h"); ?></td>
  </tr>
 <tr bgcolor="#000000">
    <td><font color="#FFFFFF"><b>CPU Information:</b></font></td>
  </tr>
  <tr bgcolor="#F0FFF0">
    <td><?php system("cat /proc/cpuinfo | grep \"model name\\|processor\""); ?></td>
  </tr>
</table>

Friday, February 10, 2012

Can't create PID PostMasterMailbox, because it's already running in OTRS

If you are getting this error " Can't create PID PostMasterMailbox, because it's already running" in SYSconfig in OTRS ADMIN

to check the processes type the command on the command prompt

#> ps -ef | grep PostMasterMailbox.pl

then go to mysql and check

mysql> select * from process_id where process_name = 'PostMasterMailbox';

mysql> delete from process_id where process_name = 'PostMasterMailbox';

and lastly run the following command to start the postmaster to fetch the mails

bin/otrs.PostMasterMailbox.pl -f 1

CronJob Setting for OTRS

To See type the command

crontab -l -u otrs (--l for list --e for edit)

[root@server ~]# crontab -e -u otrs

# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

# check daily the spool directory of OTRS
#10 0 * * * * [ -e /etc/init.d/otrs ] && /etc/init.d/otrs cleanup >> /dev/null; [ -e /etc/rc.d/init.d/otrs ] && /etc/rc.d/init.d/otrs cleanup >> /dev/null
10 0 * * * $HOME/bin/otrs.cleanup >> /dev/null
# --
# cron/postmaster_mailbox - postmaster_mailbox cron of the OTRS
# Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
# --
# $Id: postmaster_mailbox.dist,v 1.3 2009/11/09 15:24:13 mn Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

# fetch emails every 10 minutes
*/2 * * * * $HOME/bin/otrs.PostMasterMailbox.pl >> /dev/null
# --
# cron/rebuild_ticket_index - rebuild ticket index for OTRS
# Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
# --
# $Id: rebuild_ticket_index.dist,v 1.10 2009/11/09 15:24:13 mn Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

# just every day
01 01 * * * $HOME/bin/otrs.RebuildTicketIndex.pl >> /dev/null
# --
# cron/session - delete old session ids of the OTRS
# Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
# --
# $Id: session.dist,v 1.12 2009/11/04 12:27:57 mn Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

# delete every 120 minutes old/idle session ids
55 */2 * * * $HOME/bin/otrs.DeleteSessionIDs.pl --expired >> /dev/null
# --
# cron/unlock - unlock old locked ticket of the OTRS
# Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
# --
# $Id: unlock.dist,v 1.11 2009/11/04 12:27:57 mn Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

# unlock every hour old locked tickets
*/5 * * * * $HOME/bin/otrs.UnlockTickets.pl --timeout >> /dev/null

Schedule tasks on Linux using crontab

To see what crontabs are currently running on your system

#crontab -l

To edit the list of cronjobs

#crontab -e -u root

-e=edit
-u=user
root (root is user)

Cronjobs are written in the following format

* * * * * /bin/execute/this/script.sh

Scheduling explained

As you can see there are 5 stars. The stars represent different date parts in the following order:

1. minute (from 0 to 59)
2. hour (from 0 to 23)
3. day of month (from 1 to 31)
4. month (from 1 to 12)
5. day of week (from 0 to 6) (0=Sunday)

Execute every Friday 1AM

So if we want to schedule the script to run at 1AM every Friday, we would need the following cronjob:

0 1 * * 5 /bin/execute/this/script.sh

The script is now being executed when the system clock hits:

1. minute: 0
2. of hour: 1
3. of day of month: * (every day of month)
4. of month: * (every month)
5. and weekday: 5 (=Friday)

Execute on workdays 1AM

So if we want to schedule the script to Monday till Friday at 1 AM, we would need the following cronjob:

0 1 * * 1-5 /bin/execute/this/script.sh

The script is now being executed when the system clock hits:

1. minute: 0
2. of hour: 1
3. of day of month: * (every day of month)
4. of month: * (every month)
5. and weekday: 1-5 (=Monday til Friday)

Execute 10 past after every hour on the 1st of every month

Here's another one

10 * 1 * * /bin/execute/this/script.sh

Neat scheduling tricks

What if you'd want to run something every 10 minutes? Well you could do this:

0,10,20,30,40,50 * * * * /bin/execute/this/script.sh

But crontab allows you to do this as well:

*/10 * * * * /bin/execute/this/script.sh


Storing the crontab output

By default cron saves the output of /bin/execute/this/script.sh in the user's mailbox (root in this case). But it's prettier if the output is saved in a separate logfile. Here's how:

*/10 * * * * /bin/execute/this/script.sh 2>&1 >> /var/log/script_output.log

Explained

Linux can report on different levels. There's standard output (STDOUT) and standard errors (STDERR). STDOUT is marked 1, STDERR is marked 2. So the following statement tells Linux to store STDERR in STDOUT as well, creating one datastream for messages & errors:

2>&1

Now that we have 1 output stream, we can pour it into a file. Where > will overwrite the file, >> will append to the file. In this case we'd like to to append:

>> /var/log/script_output.log

Remove CPAN modules

Type the command

#yum remove perl perl-CPAN

Syntax to block an IP address under Linux

If you just want to block access to all port from an ip 65.55.44.100 then type command :

#iptables -A INPUT -s 65.55.44.100 -j DROP
#service iptables save
#service iptables restart

If you just want to block access to one port from an ip 65.55.44.100 to port 25 then type command:

# iptables -A INPUT -s 65.55.44.100 -p tcp --destination-port 25 -j DROP
#service iptables save
#service iptables restart

Unblock An IP Address:
Use the following syntax (the -d options deletes the rule from table):

# iptables -D INPUT -s 65.55.44.100 -j DROP
# service iptables save
#service iptables restart

Shows network status under Linux

Displays generic net statistics of the host you are currently connected to.

#netstat

Shows all connections to the server including the source and destination ips and ports if you have proper permissions.

#netstat -an


Displays routing table for all ips bound to the server.

#netstat -rn


Display the amount of active connections on port 80. Removing the pipe and wc command would display each connection.

#netstat -an |grep :80 |wc -l

Display active Internet connections.

#netstat -natp

Display the Port of ssh

#netstat -lntp | grep ssh

Linux top command interface details

Linux top command interface
The first row shows the same content and the uptime command, [l] can show and hide this area

First Line

top: This is not what it meant, just a name and to01:47:56: current system time

up 1:26: System boot to the elapsed time is now

2 users: currently 2 users online

load average: 0.00,0.00,0.00: System 1 minute, 5 minutes, 15 minutes of CPU load information

Second line:

Tasks: English meaning of work; task; errand.

38 total: well understood, is the current 38 missions, which is 38 processes.

1 running: 1 one process is running

37 sleeping: 37-task sleep

0 stopped: stopped processes

0 zombie: dead processes

Third Line :

Cpu (s): This line shows that the overall CPU Information

0.0% us: the user states the percentage of CPU time the process does not contain renice value is negative, the task of CPU time.

0.7% sy: the percentage of kernel CPU time

0.0% ni: renice value is negative, the task of user-process CPU time percentage. nice is the meaning of the priority

99.3% id: the percentage of idle CPU time

0.0% wa: waiting for I / O, CPU time percentage

0.0% hi: CPU percentage of time the hardware interrupt

0.0% si: CPU percentage of time the soft interrupt

0.0% st: I do not know

Fourth line:

Mem: the meaning of memory

256412k total: total physical memory

30156k used: the amount of physical memory used

226256 free: the amount of free physical memory

8176k buffers: as the amount of physical memory the kernel cache

Fifth Line

Swap: Swap Space

337356k total: total amount of swap

0k used: the amount of used swap

337356k free: the amount of free swap

12160k cached: the total buffer swap

Sixth line:

PID: process ID

USER: Process Owner

PR: process priority, the smaller the priority to be executed

NI : nice Value

VIRT: virtual memory occupied by the process

RES: the amount of physical memory the process

SHR: the process of using shared memory

S: state of the process. S indicates sleep, R for running, Z said rigid state, N is a negative number indicates that the process priority

% CPU: CPU-usage process

% MEM: memory used by the process of physical memory and the percentage of the total

TIME +: The process started after the occupation of the total CPU time that the CPU usage time of the accumulated value.

COMMAND: command name starts the process