2013年6月13日 星期四

linux cron

path:

/var/spool/cron


sample:


44 11 * * * /etc/webmin/cron/tempdelete.pl
0 * * * * /etc/webmin/bandwidth/rotate.pl
*/5 * * * * /usr/sbin/ntpdate time.stdtime.gov.tw > /dev/null 2>&1
10 6 * * * /usr/local/sbin/tarDATA_day.sh
*/1 * * * * /usr/local/sbin/webcron/pushcron.sh
59 23 * * * /usr/local/sbin/webcron/webcron.sh

execute url (wget)
and no output result


wget http://p4.milkidea.com/app_tls/api-cron.sea -O /dev/null
wget http://p4.milkidea.com/app_discovery/api-cron.sea -O /dev/null
wget http://p4.milkidea.com/clinic2/api-cron.sea -O /dev/null
wget http://p4.milkidea.com/app_pushme/api-cron.sea -O /dev/null

Linux常用指令

shutdown / reboot , reference from 鳥哥

重起sendmail
service sendmail stop
service sendmail start


重起apache

apache reset
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start


掛上一個裝置

mount -t ext3 /dev/sdb1 /mnt/data2
rm -rf *   刪除,recursive & force
cp -rf * ../data2  複製,recursive & force
fg

symboic link
ln -sf /mnt/data2 /mnt/db_disk
$ ln [參數] 來源檔案或資料夾 要建立的 link 名稱
沒有參數的時候是建立 hard link,沒辦法跨 file system,沒辦法 link directory
-s : symbolic link
-f : 要建立的 link 如果存在,會先移除掉再建立

[root@www ~]# ln -s /etc/crontab crontab2
[root@www ~]# ll -i /etc/crontab /root/crontab2
1912701 -rw-r--r-- 2 root root 255 Jan  6  2007 /etc/crontab
 654687 lrwxrwxrwx 1 root root  12 Oct 22 13:58 /root/crontab2 -> /etc/crontab

rm db_disk
umount /mnt/data
若是busy請離開/mnt/data工作目錄

要複製資料且保留權限要使用
tar cvf * -R
tar xvf 

SFTP to non port 22

注意: -oPort 參數要在前面,以避免某些程式解命令列參數時解錯。
解法範例:
sftp -oPort=6789 jjdai@example.com

apatana git 練習

設定git 執行程式

建立git儲存空間


Git功能選單


Git Add remote



2013年6月1日 星期六

vi 常用指令筆記

command mode

u  : undo
dd : delete a line
x : delete a char
o : new line
y : mask a line
p : paste
$ : goto end of a line
0 : goto start of a line

更多的介紹
c9s Vim Hacks7 是相當好的 vim 學習資源    
http://c9s.blogspot.tw/2009/08/vim-hacks-coscup.html

2013年5月31日 星期五

mysql left join - 可以利用foreign key的關聯相關表格來補充擴充欄位

select a.c1, b.c2 from a left join b on a.c1 = b.c1
其實left join 是指 把 b 沒有符合 的也列出來 但是加了 where 會強制 b.c2 一定要符合 2009-10-23

範例


//195筆
select `store_book`.* from `store_book` where  `store_book`.`store_code`='P018' and `store_book`.`seat_name`='不限定'


//34筆 - cross table 相同user_id
select `store_book`.*,`user`.`UName`,`user`.`UPhone` from `store_book`, `user` where   `user`.user_id=`store_book`.user_id  and `store_book`.`store_code`='P018' and `store_book`.`seat_name`='不限定'

用left join從user表中來擴充UName,UPhone資訊

// 195筆
select `store_book`.*,`user`.`UName`,`user`.`UPhone` from `store_book` left join `user` on   `user`.user_id=`store_book`.user_id  where `store_book`.`store_code`='P018' and `store_book`.`seat_name`='不限定'


2013年5月23日 星期四

更改DNS對應IP,移機後的Drupal無法啟動


查詢網路發現可能是cache沒有清除乾淨
---
drupal 可以用phpmyadmin清除的資料表
Which Drupal tables are safe to manually clear using phpmyadmin?

In my experience, I purge all of the "cache_*" tables.
cache
cache_*


plus "watchdog" if I don't care about past Drupal logs
plus "accesslog" if I don't care about logged-in users
plus "search" if I don't care about indexed nodes contents

boost_cache
boost_cache_relationships

----
原來問題是  drupal_test/phpBB3/config.php 裡面有資料庫設定錯了
因為當初是用IP設定連結的Orz

----
要找出這個問題可以用字串搜尋的方式
方式很多,比方像是:

linux搜尋特定字串的指令

grep -r "STRING" /path
find /path -type f | xargs grep "STRING"
----