Choose fontsize:
ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน
 
หน้า: [1]   ลงล่าง
  ตอบส่งหัวข้อนี้พิมพ์  
ผู้เขียน หัวข้อ: mysql-xtradb On CentOS  (อ่าน 866 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
nong 
บุคคลทั่วไป
« เมื่อ: 03 สิงหาคม 2011, 20:15:34 »
ตอบโดยอ้างถึงข้อความอ้างถึง

ติดตั้งระบบ yum ก่อน

rpm -ivh  http://www.percona.com/percona-builds/percona-release/percona-release-0.0-1.i386.rpm

rpm -ivh  http://www.percona.com/percona-builds/percona-release/percona-release-0.0-1.x86_64.rpm


ติดตั้ง mysql-xtradb


 yum install Percona-XtraDB-server Percona-XtraDB-client


ต้อง copy  my.cnf มาแก้เองนะครับอยู่ที่เดียวกับ my.cnf ของ mysql ปกติ
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #1 เมื่อ: 04 สิงหาคม 2011, 00:22:58 »
ตอบโดยอ้างถึงข้อความอ้างถึง

Here's a list of PHP modules you can install via yum without compiling from source:

อ้างถึง
โค๊ด:
php-odbc.x86_64 : A module for PHP applications that use ODBC databases.
php-pear-MDB2-Driver-mysql.noarch : MySQL MDB2 driver
php.x86_64 : The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php-pear-Date.noarch : Date and Time Zone Classes
php-pear-DB.noarch : PEAR: Database Abstraction Layer
php-pdo.x86_64 : A database access abstraction module for PHP applications
php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php-pear-Net-Socket.noarch : Network Socket Interface
php-cli.x86_64 : Command-line interface for PHP
php-mysql.x86_64 : A module for PHP applications that use MySQL databases.
php-cli.x86_64 : Command-line interface for PHP
php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php-mysql.x86_64 : A module for PHP applications that use MySQL databases.
php-mcrypt.x86_64 : Standard PHP module provides mcrypt library support
php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php-ldap.x86_64 : A module for PHP applications that use LDAP.
php-pear.noarch : PHP Extension and Application Repository framework
php-imap.x86_64 : A module for PHP applications that use IMAP.
php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php-readline.x86_64 : Standard PHP module provides readline library support
php-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices.
php-mhash.x86_64 : Standard PHP module provides mhash support
php-pgsql.x86_64 : A PostgreSQL database module for PHP.
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-pear-Net-SMTP.noarch : Provides an implementation of the SMTP protocol
php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php-dba.x86_64 : A database abstraction layer module for PHP applications
php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php-pear-File.noarch : Common file and directory routines
php-pear-Net-URL.noarch : Easy parsing of URLs
php-pear-HTTP-Request.noarch : Provides an easy way to perform HTTP requests
php.x86_64 : The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
php-common.x86_64 : Common files for PHP
php-pear-Log.noarch : Abstracted logging facility for PHP
php-pear-MDB2.noarch : Database Abstraction Layer
php-pear-Mail-Mime.noarch : Classes to create and decode mime messages
php-mysql.x86_64 : A module for PHP applications that use MySQL databases.
php-pgsql.x86_64 : A PostgreSQL database module for PHP.
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-pear-Net-Sieve.noarch : Communication with timsieved
php-tidy.x86_64 : Standard PHP module provides tidy library support
php-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices.
php.x86_64 : The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
php-cli.x86_64 : Command-line interface for PHP
php-pecl-Fileinfo.x86_64 : Fileinfo is a PHP extension that wraps the libmagic library
php-devel.x86_64 : Files needed for building PHP extensions.
php-dba.x86_64 : A database abstraction layer module for PHP applications
php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php-pdo.x86_64 : A database access abstraction module for PHP applications
php-mssql.x86_64 : Standard PHP module provides mssql support
php-pdo.x86_64 : A database access abstraction module for PHP applications
php-ldap.x86_64 : A module for PHP applications that use LDAP.
php-pear.noarch : PHP Extension and Application Repository framework
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php-odbc.x86_64 : A module for PHP applications that use ODBC databases.
php-pear-Auth-SASL.noarch : PEAR: Abstraction of various SASL mechanism responses
php-pear-Mail.noarch : Class that provides multiple interfaces for sending emails
php-xml.x86_64 : A module for PHP applications which use XML
php-ncurses.x86_64 : A module for PHP applications for using ncurses interfaces
php-dbase.x86_64 : Standard dBase module for PHP applications
php-devel.x86_64 : Files needed for building PHP extensions.
php-ncurses.x86_64 : A module for PHP applications for using ncurses interfaces
php-common.x86_64 : Common files for PHP
php-xml.x86_64 : A module for PHP applications which use XML
php-imap.x86_64 : A module for PHP applications that use IMAP.
php-common.x86_64 : Common files for PHP
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #2 เมื่อ: 04 สิงหาคม 2011, 00:24:44 »
ตอบโดยอ้างถึงข้อความอ้างถึง

ติดตั้ง PHP 5.3 ใน CentOS ด้วย Source
วันนี้ลองทำการทดลอง PHP 5.3 ในเครื่อง Development เพื่อทดสอบสิ่งที่เพิ่มมา โดยติดตั้งในแบบ cgi เพื่อใช้ทดลอง fast-cgi ใน nginx

ก่อนอื่นต้องติดตั้ง library ที่จำเป็นก่อน
BASH
yum install gcc gcc-c++ pcre-devel zlib-devel openssl-devel gd gd-devel curl curl-devel icu libicu libicu-devel libtool libtool-ltld-devel libtool-libs libc-client libc-client-devel pam-devel libmcrypt libmcrypt-devel

จากนั้น download php 5.3
BASH
wget http://th.php.net/get/php-5.3.0.tar.gz/from/this/mirror

แตกไฟล์
BASH
tar xzf php-5.3.0.tar.gz

เปลี่ยน directory
BASH
cd php-5.3.0

เริ่มทำการ configure
BASH
./configure --with-libxml-dir --with-openssl --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --with-curlwrappers --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-intl --enable-mbstring --with-mcrypt --with-mysql=/usr/local/mysql --enable-embedded-mysqli --enable-soap --enable-sockets --enable-wddx --enable-zip --with-imap --with-imap-ssl --with-kerberos

เสร็จแล้วก็เริ่ม compile
BASH
make

จากนั้นก็ติดตั้ง
BASH
make install

ที่มา : http://articles.modoeye.com/Operating_System/Linux_and_BSD/CentOS/%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87_PHP_5.3_%E0%B9%83%E0%B8%99_CentOS_%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2_Source.html
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #3 เมื่อ: 04 สิงหาคม 2011, 00:27:17 »
ตอบโดยอ้างถึงข้อความอ้างถึง

การติดตั้ง PHP ดูได้ที่ http://www.voip4share.com/centos-the-community-enterprise-operating-system-f55/php-5-2-t217.html

หรือ ใช้ yum
อ้างถึง
yum install php-pear  ImageMagick-devel php-gd php-mysql php-mhash php-snmp php-imap php-ldap php-mcryp php-mbstring php-tidy php-devel php-xml php-zlib
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #4 เมื่อ: 04 สิงหาคม 2011, 09:06:47 »
ตอบโดยอ้างถึงข้อความอ้างถึง

How Do I Disable Firewall?

First login as the root user.

Next enter the following three commands to disable firewall.
# service iptables save
# service iptables stop
# chkconfig iptables off

If you are using IPv6 firewall, enter:
# service ip6tables save
# service ip6tables stop
# chkconfig ip6tables off
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #5 เมื่อ: 04 สิงหาคม 2011, 09:27:05 »
ตอบโดยอ้างถึงข้อความอ้างถึง

Basic iptables howto
Iptables is a firewall, installed by default on all official Ubuntu distributions (Ubuntu, Kubuntu, Xubuntu). When you install Ubuntu, iptables is there, but it allows all traffic by default. Ubuntu 8.04 Comes with ufw - a program for managing the iptables firewall easily.

There is a wealth of information available about iptables, but much of it is fairly complex, and if you want to do a few basic things, this How To is for you.

Basic Commands
Typing

# iptables -L
lists your current rules in iptables. If you have just set up your server, you will have no rules, and you should see

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
Basic Iptables Options
Here are explanations for some of the iptables options you will see in this tutorial. Don't worry about understanding everything here now, but remember to come back and look at this list as you encounter new options later on.

-A - Append this rule to a rule chain. Valid chains for what we're doing are INPUT, FORWARD and OUTPUT, but we mostly deal with INPUT in this tutorial, which affects only incoming traffic.
-L - List the current filter rules.
-m conntrack - Allow filter rules to match based on connection state. Permits the use of the --ctstate option.
--ctstate - Define the list of states for the rule to match on. Valid states are:
NEW - The connection has not yet been seen.
RELATED - The connection is new, but is related to another connection already permitted.
ESTABLISHED - The connection is already established.
INVALID - The traffic couldn't be identified for some reason.
-m limit - Require the rule to match only a limited number of times. Allows the use of the --limit option. Useful for limiting logging rules.
--limit - The maximum matching rate, given as a number followed by "/second", "/minute", "/hour", or "/day" depending on how often you want the rule to match. If this option is not used and -m limit is used, the default is "3/hour".
-p - The connection protocol used.
--dport - The destination port(s) required for this rule. A single port may be given, or a range may be given as start:end, which will match all ports from start to end, inclusive.
-j - Jump to the specified target. By default, iptables allows four targets:
ACCEPT - Accept the packet and stop processing rules in this chain.
REJECT - Reject the packet and notify the sender that we did so, and stop processing rules in this chain.
DROP - Silently ignore the packet, and stop processing rules in this chain.
LOG - Log the packet, and continue processing more rules in this chain. Allows the use of the --log-prefix and --log-level options.
--log-prefix - When logging, put this text before the log message. Use double quotes around the text to use.
--log-level - Log using the specified syslog level. 7 is a good choice unless you specifically need something else.
-i - Only match if the packet is coming in on the specified interface.
-I - Inserts a rule. Takes two options, the chain to insert the rule into, and the rule number it should be.
-I INPUT 5 would insert the rule into the INPUT chain and make it the 5th rule in the list.
-v - Display more information in the output. Useful for if you have rules that look similar without using -v.
-s --source - address[/mask] source specification
-d --destination - address[/mask] destination specification
-o --out-interface - output name
  • network interface name (
  • for wildcard)
Allowing Established Sessions
We can allow established sessions to receive traffic:

# iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
The above rule has no spaces either side of the comma in ESTABLISHED,RELATED
If the line above doesn't work, you may be on a castrated VPS whose provider has not made available the extension, in which case an inferior version can be used as last resort:

# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Allowing Incoming Traffic on Specific Ports
You could start by blocking traffic, but you might be working over SSH, where you would need to allow SSH before blocking everything else.

To allow incoming traffic on the default SSH port (22), you could tell iptables to allow all TCP traffic on that port to come in.

# iptables -A INPUT -p tcp --dport ssh -j ACCEPT
Referring back to the list above, you can see that this tells iptables:

append this rule to the input chain (-A INPUT) so we look at incoming traffic
check to see if it is TCP (-p tcp).
if so, check to see if the input goes to the SSH port (--dport ssh).
if so, accept the input (-j ACCEPT).
Lets check the rules: (only the first few lines shown, you will see more)

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
Now, let's allow all incoming web traffic

# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Checking our rules, we have

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
We have specifically allowed tcp traffic to the ssh and web ports, but as we have not blocked anything, all traffic can still come in.

Blocking Traffic
Once a decision is made to accept a packet, no more rules affect it. As our rules allowing ssh and web traffic come first, as long as our rule to block all traffic comes after them, we can still accept the traffic we want. All we need to do is put the rule to block all traffic at the end.


# iptables -A INPUT -j DROP
# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
DROP       all  --  anywhere             anywhere
Because we didn't specify an interface or a protocol, any traffic for any port on any interface is blocked, except for web and ssh.

Editing iptables
The only problem with our setup so far is that even the loopback port is blocked. We could have written the drop rule for just eth0 by specifying -i eth0, but we could also add a rule for the loopback. If we append this rule, it will come too late - after all the traffic has been dropped. We need to insert this rule before that. Since this is a lot of traffic, we'll insert it as the first rule so it's processed first.


# iptables -I INPUT 1 -i lo -j ACCEPT
# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
DROP       all  --  anywhere             anywhere
The first and last lines look nearly the same, so we will list iptables in greater detail.

# iptables -L -v

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:ssh
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:www
    0     0 DROP       all  --  any    any     anywhere             anywhere
You can now see a lot more information. This rule is actually very important, since many programs use the loopback interface to communicate with each other. If you don't allow them to talk, you could break those programs!

Logging
In the above examples none of the traffic will be logged. If you would like to log dropped packets to syslog, this would be the quickest way:

# iptables -I INPUT 5 -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
See Tips section for more ideas on logging.

Saving iptables
If you were to reboot your machine right now, your iptables configuration would disappear. Rather than type this each time you reboot, however, you can save the configuration, and have it start up automatically. To save the configuration, you can use iptables-save and iptables-restore.

Configuration on startup
WARNING: Iptables and NetworkManager seem to have a conflict. However NetworkManager is still in Beta. If you are concerned enough about security to install a firewall you might not want to trust NetworkManager to manage it yet. Also note NetworkManager and iptables have opposite aims. Iptables aims to keep any questionable network traffic out. NetworkManager aims to keep you connected at all times. Therefore if you want security all the time, run iptables at boot time. If you want security some of the time then NetworkManager might be the right choice.

WARNING: If you use NetworkManager (installed by default on Feisty and later) these steps will leave you unable to use NetworkManager for the interfaces you modify. Please follow the steps in the next section instead.

NOTE: It appears on Hardy, NetworkManager has an issue with properly on saving and restoring the iptable rules when using the method in the next section. Using this first method appears to work. If you find otherwise, please update this note.

Save your firewall rules to a file

# sudo bash -c "iptables-save > /etc/iptables.rules"
At this point you have several options. You can make changes to /etc/network/interfaces or add scripts to /etc/network/if-pre-up.d/ and /etc/network/if-post-down.d/ to achieve similar ends. The script solution allows for slightly more flexibility.

Solution #1 - /etc/network/interfaces
(NB: I followed the directions in this section and this disabled most (all?) of my scripts in /etc/rc2.d/: polipo, dnsmasq, bluetooth, etc. I recommend using ufw/gufw instead. ~gasull)

Modify the /etc/network/interfaces configuration file to apply the rules automatically. You will need to know the interface that you are using in order to apply the rules - if you do not know, you are probably using the interface eth0, although you should check with the following command first to see if there are any wireless cards:

$ iwconfig
If you get output similar to the following, then you do not have any wireless cards at all and your best bet is probably eth0.


$ iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

$
When you have found out the interface you are using, please open your /etc/network/interfaces file depending on what editor you want and/or what distribution you have:

Command line:

# nano /etc/network/interfaces
For Ubuntu and Xubuntu: type ALT+F2, then in the window that pops up, type:

gksudo gedit /etc/network/interfaces
and press Enter.

For Kubuntu: type ALT+F2, then in the window that pops up, type:

kdesu kate /etc/network/interfaces
and press enter.

When in the file, search for the interface you found, and at the end of the network related lines for that interface, add the line:

pre-up iptables-restore < /etc/iptables.rules
You can also prepare a set of down rules, save them into second file /etc/iptables.downrules and apply it automatically using the above steps:

post-down iptables-restore < /etc/iptables.downrules
A fully working example using both from above:


auto eth0
iface eth0 inet dhcp
  pre-up iptables-restore < /etc/iptables.rules
  post-down iptables-restore < /etc/iptables.downrules
You may also want to keep information from byte and packet counters.


iptables-save -c > /etc/iptables.rules
The above command will save the whole rule-set to a file called /etc/iptables.rules with byte and packet counters still intact.

Solution #2 /etc/network/if-pre-up.d and ../if-post-down.d
NOTE: This solution uses iptables-save -c to save the counters. Just remove the -c to only save the rules.

Alternatively you could add the iptables-restore and iptables-save to the if-pre-up.d and if-post-down.d directories in the /etc/network directory instead of modifying /etc/network/interface directly.

The script /etc/network/if-pre-up.d/iptablesload will contain:


#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0
and /etc/network/if-post-down.d/iptablessave will contain:


#!/bin/sh
iptables-save -c > /etc/iptables.rules
if [ -f /etc/iptables.downrules ]; then
   iptables-restore < /etc/iptables.downrules
fi
exit 0
Then be sure to give both scripts execute permissions:

# chmod +x /etc/network/if-post-down.d/iptablessave
# chmod +x /etc/network/if-pre-up.d/iptablesload
Solution #3 iptables-persistant
Install and use the iptables-persistent package.

Configuration on Startup for NetworkManager
NetworkManager includes the ability to run scripts when it activates or deactivates an interface. To save iptables rules on shutdown, and to restore them on startup, we are going to create such a script. To begin, press Alt+F2 and enter this command:

For Ubuntu:

$ gksudo gedit /etc/NetworkManager/dispatcher.d/01firewall
For Kubuntu:

kdesu kate /etc/NetworkManager/dispatcher.d/01firewall
Then, paste this script into your editor, save, and exit the editor.

if [ -x /usr/bin/logger ]; then
        LOGGER="/usr/bin/logger -s -p daemon.info -t FirewallHandler"
else
        LOGGER=echo
fi

case "$2" in
        up)
                if [ ! -r /etc/iptables.rules ]; then
                        ${LOGGER} "No iptables rules exist to restore."
                        return
                fi
                if [ ! -x /sbin/iptables-restore ]; then
                        ${LOGGER} "No program exists to restore iptables rules."
                        return
                fi
                ${LOGGER} "Restoring iptables rules"
                /sbin/iptables-restore -c < /etc/iptables.rules
                ;;
        down)
                if [ ! -x /sbin/iptables-save ]; then
                        ${LOGGER} "No program exists to save iptables rules."
                        return
                fi
                ${LOGGER} "Saving iptables rules."
                /sbin/iptables-save -c > /etc/iptables.rules
                ;;
        *)
                ;;
esac
Finally, we need to make sure NetworkManager can execute this script. In a terminal window, enter this command:

# chmod +x /etc/NetworkManager/dispatcher.d/01firewall
Tips
If you manually edit iptables on a regular basis
The above steps go over how to setup your firewall rules and presume they will be relatively static (and for most people they should be). But if you do a lot of development work, you may want to have your iptables saved everytime you reboot. You could add a line like this one in /etc/network/interfaces:

  pre-up iptables-restore < /etc/iptables.rules
  post-down iptables-save > /etc/iptables.rules
The line "post-down iptables-save > /etc/iptables.rules" will save the rules to be used on the next boot.

Using iptables-save/restore to test rules
If you edit your iptables beyond this tutorial, you may want to use the iptables-save and iptables-restore feature to edit and test your rules. To do this open the rules file in your favorite text editor (in this example gedit).

$ sudo iptables-save > /etc/iptables.rules
$ gksudo gedit /etc/iptables.rules
You will have a file that appears similiar to (following the example above):

# Generated by iptables-save v1.3.1 on Sun Apr 23 06:19:53 2006
*filter
:INPUT ACCEPT [368:102354]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [92952:20764374]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j DROP
COMMIT
# Completed on Sun Apr 23 06:19:53 2006
Notice that these are iptables commands minus the iptable command. Feel free to edit this to file and save when complete. Then to test simply:

# iptables-restore < /etc/iptables.rules
NOTE: With iptables 1.4.1.1-1 and above, a script allow you to test your new rules without risking to brick your remote server. If you are applying the rules on a remote server, you should consider testing it with:

# iptables-apply /etc/iptables.rules
After testing, if you have not added the iptables-save command above to your /etc/network/interfaces remember not to lose your changes:

# iptables-save > /etc/iptables.rules
More detailed Logging
For further detail in your syslog you may want create an additional Chain. This will be a very brief example of my /etc/iptables.rules showing how I setup my iptables to log to syslog:

# Generated by iptables-save v1.3.1 on Sun Apr 23 05:32:09 2006
*filter
:INPUT ACCEPT [273:55355]
:FORWARD ACCEPT [0:0]
:LOGNDROP - [0:0]
:OUTPUT ACCEPT [92376:20668252]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j LOGNDROP
-A LOGNDROP -p tcp -m limit --limit 5/min -j LOG --log-prefix "Denied TCP: " --log-level 7
-A LOGNDROP -p udp -m limit --limit 5/min -j LOG --log-prefix "Denied UDP: " --log-level 7
-A LOGNDROP -p icmp -m limit --limit 5/min -j LOG --log-prefix "Denied ICMP: " --log-level 7
-A LOGNDROP -j DROP
COMMIT
# Completed on Sun Apr 23 05:32:09 2006
Note a new CHAIN called LOGNDROP at the top of the file. Also, the standard DROP at the bottom of the INPUT chain is replaced with LOGNDROP and add protocol descriptions so it makes sense looking at the log. Lastly we drop the traffic at the end of the LOGNDROP chain. The following gives some idea of what is happening:

--limit sets the number of times to log the same rule to syslog
--log-prefix "Denied..." adds a prefix to make finding in the syslog easier
--log-level 7 sets the syslog level to informational (see man syslog for more detail, but you can probably leave this)
Disabling the firewall
If you need to disable the firewall temporarily, you can flush all the rules using

# iptables -F
or create a script using text editor such as nano

# nano -w /root/fw.stop

echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
Make sure you can execute the script

$ chmod +x /root/fw.stop
You can run the script

$ /root/fw.stop
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #6 เมื่อ: 04 สิงหาคม 2011, 11:01:30 »
ตอบโดยอ้างถึงข้อความอ้างถึง

. Download syslog-ng dependencies and install it :
# wget ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/x86_64/RPMS/eventlog-0.2.5-6.el5.kb.x86_64.rpm
# rpm -i eventlog-0.2.5-6.el5.kb.x86_64.rpm
2. Download syslog-ng rpm file. Please choose the correct arch for you machine before you download the package.
# wget ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/x86_64/RPMS/syslog-ng-2.0.3-1.el5.kb.x86_64.rpm
3. Install syslog-ng with force
# rpm -i –force –nosignature syslog-ng-2.0.3-1.el5.kb.x86_64.rpm
4. Disable default syslog and set syslog-ng to take over the job.
# chkconfig syslog off
# chkconfig syslog-ng on
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #7 เมื่อ: 04 สิงหาคม 2011, 14:47:54 »
ตอบโดยอ้างถึงข้อความอ้างถึง

rpm -Uvh *.rpm --nodeps --force

ถ้ามี Error

error: Failed dependencies

rpm -e --nodeps rsyslog ## ลบดีจัง

#############################
# service rsyslog stop
# rpm -e --nodeps rsyslog
# yum install syslog-ng
# chkconfig syslog-ng on
# service syslog-ng start
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #8 เมื่อ: 04 สิงหาคม 2011, 15:36:47 »
ตอบโดยอ้างถึงข้อความอ้างถึง

EPEL6 brings syslog-ng to the latest RHEL, CentOS and SL


>> add the EPEL repository using information at HTTP://FEDORAPROJECT.ORG/WIKI/EPEL
>> # yum install --enablerepo=epel syslog-ng
>> # chkconfig rsyslog off; chkconfig syslog-ng on
>> # service rsyslog stop; service syslog-ng start

ก่อนอื่นติดตั้ง EPEL repository ก่อน ถึงจะใช้ --enablerepo=epel  ได้ โดย

Install EPEL Repository
Download the latest EPEL repository
        # wget http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm
Run the rpm install command
         # rpm -Uvh epel-release-5*.rpm
Configure EPEL Repository
Open the EPEL repository file
          /etc/yum.repos.d/epel.repo
Set priority for the EPEL repository
          Add priority=3 to the end of the [epel] section

แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #9 เมื่อ: 04 สิงหาคม 2011, 23:27:18 »
ตอบโดยอ้างถึงข้อความอ้างถึง

น่าสนใจ ลอก เขา มา ไว้ แต่ Version เก่าไปหน่อย

ลองๆตามนี้ ผมเอามาจากไหนไม่รุ จำไม่ได้แระ ...


หลาย ๆ องค์กรเริ่มจะตื่นตัวกับพรบ.ว่าด้วยการกระทำผิดเกี่ยวกับคอมพิวเตอร์ พ.ศ. ๒๕๕๐ ตามมาตรา ๒๖ บัญญัติให้ผู้ให้บริการต้องเก็บข้อมูลจราจรคอมพิวเตอร์ไว้ไม่ต่ำกว่า ๙๐ วัน แต่ไม่เกิน ๑ ปีไปแล้ว วันนี้จะแนะนำวิธีง่าย ๆ ที่จะทำ centralized log เซิร์ฟเวอร์ด้วยตนเอง ด้วยซอฟต์แวร์ open sourceดูสิว่าจะสู้ผลิตภัณฑ์ต่างประเทศราคาหลายแสนได้หรือไม่

นับเป็นข่าวดีมากที่ผู้เขียนได้ค้นพบซอฟต์แวร์ที่ใช้ทำการวิว ค้นหาข้อมูล เพื่อจะได้ทำรายงานเบื้องต้นได้ใหม่ ชื่อว่า “php syslogviewer” แถมเพิ่งจะอัพเดทล่าสุดเมื่อปีกลาย แจ่มทีเดียว ใครหลายคนอาจเคยได้ยินชื่อ phpsyslog-ng มาก่อน ลืมไปได้เลยครับขี้เหร่มาก



ซอฟต์แวร์ที่ใช้งาน

syslog-ng-2.0.0

phpsyslogviewer-7.2.1

speedupd-7.3.2



ผู้เขียนทดสอบโดยติดตั้งบนระบบปฏิบัติการ debian etch 4.0 รันในระบบเวอร์ชอลแมชชีน โดยซอฟต์แวร์ xen opensource ใช้เคอร์เนลเวอร์ชั่น 2.6.18-4-xen-686 นับว่ามีเสถียรภาพสูงมาก ๆ ครับ



ขั้นตอนที่ 1 เริ่มกันเลยดีกว่า หลังจากติดตั้งโอเอสเรียบร้อยให้ทำการติดตั้งซอฟต์แวร์ syslog-ng-2.0.0 โดยใช้แพ็คเกจของโอเอสเองดังนี้



# apt-get install syslog-ng



ขั้นตอนที่ 2 ดาวน์โหลดซอร์สโค๊ดจาก sourceforge ตามลิงค์ข้างล่างนี้

# wget http://jaist.dl.sourceforge.net/sourceforge/phpsyslogviewer/phpsyslogviewer-7.2.1.tar.bz2

# wget http://jaist.dl.sourceforge.net/sourceforge/phpsyslogviewer/speedupd-7.3.2.tar.bz2


ขั้นตอนที่ 3 แตกแพ็คเกจออกถ้าใครยังไม่ได้ลงโปรแกรม bzip2 ให้ทำการลงซะก่อนมิฉะนั้นจะแตกไฟล์ออกไม่ได้และทำการติดตั้งชุด lamp สำหรับเครื่องแม่ข่ายซะก่อน ขั้นตอนการติดตั้ง lamp อาจจะใช้เวลาสักนิดนึง หากใครมีประสบการ์ณคงหาทางแก้ปัญหาได้จากเอกสารอื่น เนื้อหาในบทความนี้ผู้เขียนขอเล็งไปที่ซอฟต์แวร์หลัก ๆ ของระบบการจัดการข้อมูลการจราจรคอมพิวเตอร์ ตามพรบ.เป็นหลัก อาจจะทำให้มือใหม่งุดหงิดบ้าง ดังนี้

# apt-get install bzip2

# tar xjvf phpsyslogviewer-7.2.1.tar.bz2

# cd phpsyslogviewer-7.2.1

# apt-get install mysql-client mysql-server apache2 php5

# apt-get install php5-mysql php5-ldap php5-cli libapache2-mod-php5



ขั้นตอนที่ 4 ในโฟลเดอร์ install จะมีสคริปที่ใช้ติดตั้งตารางต่าง ๆ ให้กับฐานข้อมูล เราจะต้องทำการสร้างฐานข้อมูลเสียก่อน มิฉะนั้นจะพบกับข้อผิดพลาดและไม่สามารถรันสคริปดังกล่าวผ่านได้

# mysql -u root -p

mysql > create database syslogng;

mysql > exit;

# mysql -u root -p syslogng < install/phpsyslogviewer.sql



ขั้นตอนที่ 5 ปรบมือให้กับตัวเองเราผ่านพ้นขั้นตอนที่ต้องระวังไปขั้นหนึ่ง จากนั้นกำหนดค่าเพื่อสร้างบัญชีรายชื่อผู้ใช้และรหัสผ่านง่าย ๆ ก็ใส่ค่าข้อมูลของผู้ใช้ รหัสผ่าน ชื่อโฮสต์ และ ฐานข้อมูล คิดว่าไม่น่ายาก ดังนี้

# vi install/newuser.sql.php

# php install/newuser.sql.php

# php install/newuser.sql.php | mysql -u root -p syslogng



ขั้นตอนที่ 6 จัดการเวบไดเรคทอรีเพื่อให้สามารถเรียกดูข้อมูลผ่านเวบบราวเซอร์ ใครที่มีประสบการณ์สร้างเวบไซต์มาก่อน งานนี้กินเรียบครับ ทำตามขั้นตอนได้เลย

# cp -R htdocs /var/www/phpsyslogviewer

# vi /var/www/phpsyslogviewer/config.php

# chown root:www-data /var/www/phpsyslogviewer/config.php

# chmod 440 /var/www/phpsyslogviewer/config.php





ขั้นตอนที่ 7 ทดลองเปิดหน้าเวบไซต์ดูหน่อยว่าหน้าตาเป็นอย่างไร ไปที่ http://xxx.xxx.xxx.xxx/phpsyslogviewer

 
จะเห็นว่าหน้าตาดูดีทีเดียว


ขั้นตอนที่ 8 ติดตั้งแพ็คเกจ speedupd-7.3.2 เพื่อเร่งความเร็วให้เอนจิ้นป้อนข้อมูลสู่ฐานข้อมูล mysql ขั้นตอนนี้อาจยุ่งยากนิดหน่อย เพราะต้องทำการคอมไพล์แพ็คเกจด้วยตัวเองใหม่ แต่ไม่เกินความสามารถของเราหรอกครับ ขอย้ำว่าต้องทำนะครับขั้นตอนนี้ มิฉะนั้นใครที่เคยใช้ phpsyslog-ng จะรู้ซึ้งว่าอึดอัดเป็นอย่างไร

# tar xjvf speedupd-7.3.2.tar.bz2

# cd speedup-7.3.2

# apt-get install debhelper cmake libdaemon-dev libconfuse-dev fakeroot

# dpkg-buildpackage -rfakeroot



ขั้นตอนที่ 9 หลังจากผ่านขั้นตอนที่ 8 เราจะได้แพ็คเกจตระกูล debian ชื่อว่า speedupd_7.3.0_i386.debให้ติดตั้งแพ็คเกจและกำหนดค่าให้กับไฟล์ speedupd.confดังนี้

# cd ..

# dpkg -i speedupd_7.3.0_i386.deb

# vi /etc/speedupd.conf

# /etc/init.d/speedupd start



ขั้นตอนที่ 10 สบายใจไปอีกขั้นหนึ่งครับ ต่อไปเป็นการกำหนดค่าให้กับ syslog-ng ทำการส่งค่าไปเก็บยังฐานข้อมูลทำตามนี้เลยครับ ง่าย ๆ ผู้เขียนตัดวิธีการเก็บข้อมูลการจราจรคอมพิวเตอร์ส่วนอื่นออก เพื่อให้สามารถทำความเข้าใจได้ง่าย ๆ ครับ หากใครมีไฟล์คอนฟิคเก่าอยู่แล้วก็เพิ่มเติมเฉพาะส่วนที่ต้องการเก็บข้อมูลในฐานข้อมู
ลได้เลยครับ

# cd /etc/syslog-ng

# cp syslog-ng.conf syslog-ng.conf.org

# vi syslog-ng.conf

options {

recv_time_zone (+07:00);

send_time_zone (+07:00);

sync (0);

time_reopen (100);

log_fifo_size (1000);

long_hostnames (off);

use_dns (no);

use_fqdn (no);

create_dirs (yes);

chain_hostnames(yes);

keep_hostname (yes);

};



source s_sys {

file ("/proc/kmsg" log_prefix("kernel: "));

unix-stream ("/dev/log");

internal();

udp(ip(0.0.0.0) port(514));

tcp(ip(0.0.0.0) port(514) keep-alive(yes));

};

destination d_mysql { \

pipe("/var/log/mysql.pipe" \

template("INSERT INTO logs \

(host, facility, priority, level, tag, datetime, program, msg) \

VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', \

'$PROGRAM', '$MSG' );\n") template-escape(yes));

};



filter f_kernel { facility (kern); };

filter f_messages { level(info..emerg) and not (facility(mail) or \

facility(authpriv) or facility(cron)); };



log {source(s_sys); filter(f_messages); destination(d_mysql); };

log {source(s_sys); filter(f_kernel); destination(d_mysql); };



ขั้นตอนที่ 11 สร้างสคริปเพื่อทำไปน์สำหรับส่งค่าสตรีมจากไปน์สู่ฐานข้อมูล งานนี้เป็น bash สคริปครับทำเสร็จต้องเปลี่ยนสิทธิให้รันได้ด้วยอย่าลืม ฟังดูวุ่นวายแต่ทำจริงง่ายมากครับ

#vi syslog2mysql.sh

#!/bin/bash

if [ ! -e /var/log/mysql.pipe ]

then

mkfifo /var/log/mysql.pipe

fi

while [ -e /var/log/mysql.pipe ]

do

mysql -u root --password=radius syslogng < /var/log/mysql.pipe >/dev/null

done



# chmod +x syslog2mysql.sh

# ./syslog2mysql.sh &

# /etc/init.d/syslog-ng start



ทำครบแล้วก็ปรบมือให้ตัวเองครับ ลองมาดูผลงานสิว่าเป็นไงบ้าง เข้าไปหน้าล็อกอินครับ
 
จากนั้นป้อนรหัสผู้ใช้พร้อมรหัสผ่านที่ทำไว้ในขั้นตอนที่ 5 ครับ ถ้าหากลืม จากนั้นจะได้หน้าจอต่อไปครับ
ดูต่อ อยากเห็นเรียลไทม์วิวเวอร์ครับ
ลองค้นหาดูสิ
 
ได้คำตอบตามนี้ครับ
 
ดูดีทีเดียวครับ เป็นไงครับ php syslogviewerสู้ซอต์ฟแวร์แพง ๆ จากต่างประเทศได้ไหมอันนี้ต้องพิสูจน์ด้วยตนเองแหละครับ ในส่วนตัวของผู้เขียนดูดีทีเดียวทะเลาะได้กับ kiwi syslog service manager ของวินโดร์ได้ดีเชียวครับ หรือจะใช้สำหรับมอนิเตอร์โปรแกรมจัดส่งข้อมูลการจราจรคอมพิวเตอร์จากอุปกรณ์อื่น ๆ เช่น สวิตช์ เร้าเตอร์ หรือ อุปกรณ์แอคเซสพอยท์ในระบบก็ทำได้ดีครับ ใช้จริงก็ได้ครับ ผู้เขียนว่าคนไทยเก่งครับ สามารถสร้างเครื่องแม่ข่ายเก็บข้อมูลการจราจรคอมพิวเตอร์ ตาม พรบ.ว่าด้วยการกระทำผิดเกียวกับคอมพิวเตอร์ พ.ศ.2550 ได้ด้วยตนเองครับ ก็มันกฎหมายบ้านเรา ก็ทำมันซะเองสิครับ แค่นี้ก็รอดตัวจากมาตรา 26 ปรับตั้งห้าแสนบาทแล้วครับ ที่สำคัญช่วยลดปัญหาการนำเข้าฮาร์ดแวร์ราคาแพงจากต่างประเทศได้ครับ สงสารพี่น้องเกษตรกรไทยครับไม่รู้จะขายข้าวสารกี่เกวียนจะพอจ่ายเงินซื้อ centralized log จากต่างประเทศสักตัว

ที่มา http://www.tpit.co.th/

supakitd at yahoo dot com

บริษัท ไทยพรอสเพอรัสไอที จำกัด

42/1 ถ.พิทักษ์ชาติ ต.ประจวบคีรีขันธ์

อ.เมืองประจวบคีรีขันธ์ จ.ประจวบคีรีขันธ์ 77000

Posted by: TonHor Jul 10 2008, 04:09 PM
ขอบคุณครับ ใช้ syslog-ng เหมือนกัน

แต่ตัวดู log บน web มีอีกตัวหนึ่งน่าใช้เหมือนกันครับ คือ http://code.google.com/p/php-syslog-ng/downloads/list

การแสดงผลและคิวรี่ คล้ายๆกับ phpsyslogviewer ดูจากในรูป

ไม่รู้ว่า phpsyslogviewer มีกราฟหรือเปล่า ของ php-syslog-ng จะมีกราฟด้วย

ที่มา :http://www.hadyaiinternet.com/index.php?topic=404.0
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #10 เมื่อ: 04 สิงหาคม 2011, 23:32:53 »
ตอบโดยอ้างถึงข้อความอ้างถึง

โค๊ด:
#!/bin/bash

if [ ! -e /var/log/mysql.pipe ]
then
   mkfifo /var/log/mysql.pipe
fi
while [ -e /var/log/mysql.pipe ]
do
   mysql -u root --password=password  syslog < /var/log/mysql.pipe >/dev/null
done
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #11 เมื่อ: 05 สิงหาคม 2011, 00:40:37 »
ตอบโดยอ้างถึงข้อความอ้างถึง

แบบ นี้ยังไม่ได้ลอง
โค๊ด:
destination d_mysql {
program(
"mysql -u syslogfeeder --password=xxxxxxxx syslog -B > /dev/null"
template("INSERT INTO logs (host, facility, priority,
level, tag, datetime, program, msg) VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL',
'$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', '$PROGRAM', '$MSG' );\n")
template-escape(yes)
);
};
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #12 เมื่อ: 06 สิงหาคม 2011, 19:23:56 »
ตอบโดยอ้างถึงข้อความอ้างถึง

เครื่องที่ไม่มี Crontab

# yum -y install vixie-cron.x86_64
# /sbin/service crond start
# /sbin/chkconfig crond on

หรือ กรณีที่ลง epel ไปแล้ว

yum install --enablerepo=epel crontabs
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
nong 
บุคคลทั่วไป
« ตอบ #13 เมื่อ: 07 สิงหาคม 2011, 09:19:56 »
ตอบโดยอ้างถึงข้อความอ้างถึง

การ ตั้งเวลา reboot ด้วย crontab บน CentOS
วิธีการทำนั้นงายมากครับใช้วิธีการเข้าไปเพิ่มการทำงาน crontab ด้วยคำสั่ง

# crontab -e
จากนั้นเพิ่มช่วงเวลาเพื่อ reboot ครับตัวอย่างผมอยากให้เครื่อง reboot ทุกวันในเวลา 2.00 ด้วยคำสั่ง
# 0 2 * * * /sbin/shutdown -r now
จากนั้นก็ :wr เพื่อ save ครับ และเริ่มการทำงานของ crontab ใหม่โดยใช้คำสั่ง
# service crond restart

คำสั่ง crontab

คำสั่ง crontab เป็นคำสั่งใน การทำ schedule ในการสั่งโปรแกรม หรือ script ต่างๆ ทำงานตามเวลาที่กำหนด บนระบบ UNIX/LINUX
ซึ่งอำนวยความสะดวก ได้มากเลยที่เดียว งานบางอย่างที่จำเป็นต้องทำซ้ำๆในเวลาเดียวกัน ไม่ว่าจะทุกวัน ทุกสัปดาห์ หรือ ทุกเดือน
การใช้ งาน crontab
------------------------
คำสั่ง และ option ของ crontab มี ดังนี้
Code:
crontab filename การนำเอาคำสั่ง crontab เข้ามาจาก ไฟล์อื่น
crontab -e แก้ไข crontab ปัจจุบัน
crontab -l ดูคำสั่ง crontab ทั้งหมดที่มีอยู่
crontab -r ลบคำ สั่ง crontab ที่มีทั้งหมด
crontab -u user เป็นคำสั่งของผู้ดูแลระบบเท่านั้น(administrators) เพื่อใช้ดู แก้ไข ลบ crontab ของ user แต่ ล่ะคน
เมื่อเรียกคำสั่งตามข้างบนแล้ว crontab จะ เข้าสู่ระบบการ กำหนด หรือ แก้ไข ซึ่งการ กำหนด หรือแก้ไขนี้ จะเหมือนกับการใช้งาน vi ครับ
การกำหนดให้ crontab ทำงาน
-------------------------------------
format ของคำสั่ง crontab มีทั้งหมด 6 fields เป็นดังบรรทัดข้างล่าง
Code:
minute(s) hour(s) day(s) month(s) weekday(s) command(s)
fields 1-5 เป็นการกำหนดเวลา และ field ที่ 6 เป็นการกำหนดคำสั่ง ดังความหมายของแต่ละ fields ดังต่อไปนี้
Code:
...
Field มีค่า รายละเอียด
...
minute 0-59 เวลา เป็นนาที จะสั่งให้คำสั่งที่กำหนดทำงานทันทีเมื่อถึง
hour 0-23 เวลา เป็นชั่วโมง จะสั่งให้คำสั่งที่กำหนดทำงานทันทีเมื่อถึง
day 1-31 เวลาเป็นวัน จะสั่งให้คำสั่งที่กำหนดทำงานทันทีเมื่อถึง
month 1-12 เวลา เป็นเดือน จะสั่งให้คำสั่งที่กำหนดทำงานทันทีเมื่อถึง
weekday 0-6 วัน ของแต่ละสัปดาห์ มีค่าดังนี้ (อาทิตย์ = 0, จันทร์ = 1, อังคาร = 2, พุธ = 3, พฤหัส = 4, ศุกร์ = 5 และ เสาร์ = 6)
command คำสั่ง เราสามารถกำหนดคำสั่งได้มากมาย รวมทั้ง script ต่างๆ ตามที่เราต้องการ
...
ตัวอย่างการกำหนด crontab
---------------------------------
การเพิ่ม crontab โดยเรียกใช้คำสั่ง crontab -e เมื่อ เข้าสู่โปรแกรมแล้ว กด i เพื่อเพิ่ม คำสั่งดังตัวอย่างด้านล่างนี้เข้าไป แล้วทำการบันทึกแล้วออกมาโดยกด Esc แล้วกด :wq!
Code:
0 12 * * * /etc/python.py
จากคำสั่งด้านบนจะเป็นการสั่งให้รัน script python.py ตอน 12:00 น. ของทุกๆวัน
Code:
0 12 * * 1 /root/wifilogs.py
จากคำสั่งด้านบน จะทำการ Run script getlogs.pl ที่ path /home/tuxzilla ทุกวันจันทร์ ทุกๆเดือน ตอนเที่ยง
Code:
0 0 * * 1,2 / root/wifilogs.py
คำสั่งนี้เหมือนคำสั่งด้านบนครับ แต่จะเพิ่มการทำงานในวันอังคารด้วย ซึ่งเราสามารถใช้ "," คั่นไปเรื่อยๆได้ เพื่อที่จะกำหนดเพิ่มให้แต่ล่ะ fields หรือใช้ "*"
เพื่อการกำหนดเป็นทั้ง หมด(หมายความว่า หากที่ field ชั่วโมง เป็น * ก็หมายความว่าต้องทำงานทุกชั่วโมง)
ถึงจะมีหลาย user ใน เครื่องเดียวกันแต่ยังไง crontab ก้ยังเป็นของใคร ของมันไม่กวนกันครับ และไม่สามารถดูของกันและกันได้ นอกจากเป็น ผู้ดูแลระบบครับ ถึงตรงนี้แล้วก็คงไม่มีอะไรยากเกินกว่าแล้ว หากแต่ความสะดวกเท่านั้นที่จะมาแทนที หรือใครจะเอามาเป็นนาฬิกา อย่างผมก็ไม่ว่าครับ

ที่มา http://sabaylinux.blogspot.com/2009/07/crontab.html
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า
หน้า: [1]   ขึ้นบน
  ตอบส่งหัวข้อนี้พิมพ์  
 
กระโดดไป:  

Powered by SMF 1.1.4 | SMF © 2006, Simple Machines LLC | Thai language by ThaiSMF
Forum Pangmapha Hospital Power Byed | ICT Pangmapha Hospital | XHTML | CSS