Sunday 31 July 2011

Using cron to run programs on a schedule


**Using cron to run programs on a schedule is very useful feature  :--

Cron is a Linux system process that will execute a program at a preset time, To use cron you must prepare a text file that describes the program that you want executed & the times that cron should execute them, Then you use the crontab program to load the text file that describes the cron jobs into cron.

Here is the format of a cron job file:

[min] [hour] [day of month] [month] [day of week] [program to be run]

where each field is defined as
[min] Minutes that program should be executed on. 0-59. Do not set as * or the program will be run once a minute.
[hour] Hour that program should be executed on. 0-23. * for every hour.
[day of month] Day of the month that process should be executed on. 1-31. * for every day.
[month] Month that program whould be executed on. 1-12 * for every month.
[day of week] Day of the week. 0-6 where Sunday = 0, Monday = 1, ...., Saturday = 6. * for every day of the week.
[program] Program to be executed, Include full path information.

Here are some examples below:-

0,15,30,45 * * * * /usr/bin/foo

Will run /usr/bin/foo every 15 minutes on every hour, day-of-month, month, and day-of-week. In other words, it will run every 15 minutes for as long as the machine it running.

10 3 * * * /usr/bin/foo

Will run /usr/bin/foo at 3:10am on every day.

10 * 1 * * /usr/bin/foo

Will run /usr/bin/foo at 12:10am on the first day of the month.

10 * * 1 * /usr/bin/foo

Will run /usr/bin/foo at 12:10am on the first month of the year.

10 14 * * 1 /usr/bin/foo

Will run /usr/bin/foo at 2:10pm on every Monday.


You must use crontab to load cron jobs into cron. First create a text file that uses the above rule to describe the cron job that you want to load into cron. But before you load it, type crontab -l to list any jobs that are currently loaded in crontab.

If none are listed, then it is safe to load your job,Example. If you wanted to run /usr/local/bin/foo once a day at 3:10am, then create a text file

10 3 * * * /usr/bin/foo

Save it as foo.cron. Then type crontab foo.cron. Check to see if it was loaded by typing crontab -l. It should display something like this:

# DO NOT EDIT THIS FILE - edit the master & reinstall.
# (ipwatch.cron installed on Thu Nov 18 11:48:02 2009)
# (Cron version -- $Id: crontab.c,v 2.13 2004/01/17 03:20:37 vixie Exp $)
10 3 * * * /usr/bin/foo

If you want to edit the cron job, then edit foo.cron and then remove the existing cron job (crontab -r) and load it again (crontab foo.cron). You can have multiple jobs. Just put each different one on a seperate line in foo.cron.

contab jobs will run under the user that was in effect when you loaded the job in crontab.
 
 
*******************************************************************************

Saturday 30 July 2011

To clear Domlogs


*// Just use the given command below and you have done :-
 
 
---------------------------------
cd /usr/local/apache/domlogs/
for x in `ls`;
do
echo "" > $x;
done;
 
-------------------------------

Thursday 28 July 2011

Some Important Exim Commands


** Queues information along with commands :-

 
**USE** Print a count of the messages in the queue- Quote:-

              root@localhost# exim -bpc

2   
  
**USE** Print a listing of the messages in the queue (time queued, size, message-id, sender, recipient):
Quote:-

             root@localhost# exim -bp
3
 
**USE** Print a summary of messages in the queue (count, volume, oldest, newest, domain, and totals)
Quote:-

              exim -bp | exiqsumm

4
 
**USE**Generate and display Exim stats from a logfile Quote:-

              eximstats /path/to/exim_mainlog
5
 
**USE** Generate and display Exim stats from a logfile, with less verbose output Quote:-

               eximstats -ne -nr -nt /path/to/exim_mainlog

6
 
**USE**Generate and display Exim stats from a logfile, for one particular day Quote:-

               fgrep 2007-02-16 /path/to/exim_mainlog | eximstats

7
 
**USE** Print what Exim is doing right now Quote:-

               exiwhat

8
 
**USE** How many Frozen mails on the queue :-

               exim -bpr | grep frozen | wc -l
9
 
**USE**To delete frozen emails Quote:-

               exim -bpr | grep frozen | awk {'print $3'} | xargs exim -Mrm

10
 
**USE** To deliver emails forcefully Quote:-

               exim -qff -v -C /etc/exim.conf &
11
 
**USE**To Flush all mail in  queue :-
               exim -qff
 
***************************------------------------- ***************************

Wednesday 27 July 2011

*What is Frontpage Error fix

** Error message on the screen will be like this :-

Error: The server extensions were unable to access the file "..htaccess.tmp". Please check the file permissions.

Setting Password

Frontpage passthough auth enabled!

---------------*************---------------

To solve this follow this commands:-

cd /usr/local/frontpage/version5.0/bin/

./owsadm.exe -o install -u username -p 80 -m www.domain.com -servconf /usr/local/apache/conf/httpd.conf -xuser username

Note:-( Even if you still receive some errors on .htacess files under the domain rename those .htaccess files, This will resolve the permission issues and .htaccess problems.)

Once the above is done- Try to reinstall Frontpage extensions on the domain.

********************************************

Monday 25 July 2011

What is Frozen messages with Exim

 * follow the step listed below an d you have done it :-

...................

** Solution What are frozen messages?

Ans:-Frozen messages are messages that Exim will no longer attempt to deliver, You can thaw the message with.

      exim -Mt <message-id> [ <message-id> ... ]

...................


** To remove all frozen messages:-

     exiqgrep -z -i | xargs exim -Mrm

...................


** To show frozen messages:-

     exim -bp | grep frozen

...................


** Freeze all queued messages from local user:-

     exiqgrep -i -f luser@localhost | xargs exim -Mf


...................**************...................

Friday 22 July 2011

How to clean Exim's Mail queue


*** Solution How to clean an Exim queue is as follows :-

1) How to clean an Exim queue
2) Using WebHost Manager
3) Advanced Users
4) Very Advanced Users
 
*************---------------**************

*** Using WebHost Manager--

1. Login to WHM.
2. On the Main page, click on the email icon.
3. In the mail menu, select "Manage Mail Queue".
* Note:-( Instead of steps 2 & 3, you can select "Manage Mail Queue from the left margin.)
4. Find the message you wish to delete & select "Delete".

*************---------------**************

*** Advanced Users--

There are many times when a mail queue may become filled with what is essentially junk mail, At extreme levels, this can cause high load & delayed mail delivery.
You can use a variation of the following command via a shell prompt to delete only these junk messages from the mail queue.

grep -lR KEYWORD /var/spool/exim/input/* | xargs rm -f

(This will purge the mail queue of any messages that contain KEYWORD.
Any messages deleted in this manner are IRRETRIEVABLE (aka: Gone for good)
Is this dangerous? You bet it CAN be.)

Let's look at an example:-

Imagine a case in which users are abusing a bad FormMail.pl installation on server.fastservers.net. Almost all of these messages will contain the username "nobody@server.fastservers.net". We want to delete ALL of these messages, so we would insert "nobody@server.fastservers.net" in place of "KEYWORD" in the command above.
This will delete all messages in the exim queue that contain the keyword "nobody@server.fastservers.net".

*************---------------**************

*** Very Advanced Users--

Grep does regular expressions, This means you can catch tricky spammers with a little mind power.

 For example:-

grep -lRP Vz*Az*Lz*Iz*Uz*M /var/spool/exim/input/* | xargs rm -f

This command will delete any message containing the letters V, A, L, I, U, M, in that order, And with 0 or more "z" characters between them. A few of the keywords it will match are listed:
VALIUM
VzALIUM
VAzLIzUzM
VALzIUM
VzALzIUM
You get the idea.
 
*************---------------**************

Thursday 21 July 2011

How to install postgresql


Steps given below :-

*Not:- C-Panel requires Postgresql 7.3.x or later. 7.2.x will not work.

 
<Step 1>.

Upgrade to cPanel 7.4.0 build 45 or later,

--Step 1a --(If you do not have 7.2.x or earlier installed skip this step)

Login to a root shell via ssh or the console,

If you have Postgres 7.2.x installed, backup your databases using pg_dumpall or some other method,

Move the postgres data directory somewhere else. ie,

mv /var/lib/pgsql /var/lib/pgsql.old

---------------------------------------------------------------------------
<Step 2>.

Login to a root shell via ssh or the console and run,

/scripts/installpostgres


--Step 2a-- (skip this step if you are not upgrading from postgres 7.2 or earlier)

Restore your sql dump created with pg_dumpall or by some other method using psql or some other method



---------------------------------------------------------------------------
<Step 3>

Login to Web Host Manager & choose "Postgres Config" under Server Setup,

Set a postgres password to anything of your choosing, You should avoid using any non-alpha numeric charaters as these cause problems.


---------------------------------------------------------------------------
<Step 4>.

Use the "Postgres Config" option in WHM to install a postgres pg_hba.conf file, You can skip this step if you would like to setup your pg_hba.conf file manually, cPanel should work fine with md5 passwords or plaintext  passwords.

---------------------------------------------------------------------------


<Step 5>.

Login to cPanel and click on Postgres .. Enjoy!
 
 
******************************************--------------------------****************************************

Tuesday 19 July 2011

How To change IP in server

Note:- Hey Remember //You need to set RDNS for the IP then and then Only you can proceed further//.

***********---------------------------------------------------------------***********

If you are in the danger of getting your main server IP block by SpamCop because you had a few anoying spamers abusing your server, then you could simply change your exim mailserver IP to avoid the effect of your main IP beeing blacklisted.

--Below there are some simple steps of changing your exim IP:---

Inside both incoming & outgoing exim mail server you will need to add an interface :-
( So just edit )

pico /etc/exim_outgoing.conf

and

pico /etc/exim.conf

find
remote_smtp:
driver = smtp

& add interface = ip.you.want.to.use


***********---------------------------------------------------------------***********

Example is as shown below:-

remote_smtp:
driver = smtp
interface = 22.22.22.22

***********---------------------------------------------------------------***********

IP needs to be on server in order for this to work, hopefully this will help.
BTW: Just a reminder - If there is an exim update when you upgrade your cpanel server you will need to re-enter the interface again.




---------------------***********************************-------------------------

Friday 8 July 2011

Steps to install IP Table

This are some important steps for install (IP) tables:-


1.  Get the iptables tarball containing all the needed files.-

       - To get the latest version of iptables go to netfilter.org
       - Downloads are available at http://www.netfilter.org/downloads.html
       - The file should be named iptables-1.*.*.tar.bz2 where the asterisks represent the numbers of the       latest version.
       - Save this file to a temporary directory, we will use /tmp in this example.


 2. Open a terminal window.



 3. Change your directory to where you saved iptables by typing :-

      # cd /tmp



4. Uncompress the archive to the /usr/src directory by typing :-

      # tar -xvjf ./iptables-1.*.*.tar.bz2 -C /usr/src

      where the asterisks represent the version number of the file you downloaded,



5. Change to the directory it created (typically iptables-1.*.*), by typing :-

      # cd /usr/src/iptables-1.*.*



6. Using the kernel directories above, type :-

      # /bin/sh -c make



7. To finish the install, type :-

      # /bin/sh -c make install


- Iptables should now be installed, You can test the installation as described in the beginning of this section to see if it is working.

- If the above install steps seemed to execute without any error, but typing:-

# iptables -V

- Brings up an error, it is possible that the program did'n install itself to the sbin directory, To fix this type the following command from the iptables-1.*.* directory:

ComputerName:~# cp ./iptables /sbin

----------------------******************-------------------------