mac cron launchctl & OSX FTP LOG

  • Category: 電腦相關
  • Last Updated: Friday, 21 August 2015 16:11
  • Published: Friday, 07 August 2015 09:23
  • Written by sam

幫mac mini 安排行程

目前較新式的系統皆已預設停止cron的運作

要安排新的服務通常是使用launchctl 指令來控制

需要先在路徑新建立.plist

dev:~ samlin$ cat Library/LaunchAgents/com.apple.samsync.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
     <dict>
       <key>Label</key>
       <string>samsync</string>
       <key>Program</key>
       <array>
          <string>/Users/samlin/aaaaa</string>
       </array>
       <key>StartInterval</key>
       <integer>180</integer>
       <key>RunAtLoad</key>
       <true/>
     </dict>
</plist>

上面的內容主要是180秒執行乙次命令

請一定要確定指令(/Users/samlin/aaaaa)是能運作的

所以主要的指令是位於aaaaa的

再來請使用指令將它載入

launchctl load /Users/samlin/Library/LaunchAgents/com.apple.samsync.plist

在載入時如果有報錯

Solving launchctl load “nothing found to load”

請使用指令先行檢查

plutil -lint /Users/samlin/Library/LaunchAgents/com.apple.samsync.plist

停止指令

launchctl unload /Users/samlin/Library/LaunchAgents/com.apple.samsync.plist

快速執行命令(供測試)

dev:~ samlin$ launchctl start samsync

這邊的名稱指的是在plist裡面定義的名稱並非檔案名稱

我的目的只是寫了條RSYNC指令來同步資料夾而已…

rsync -r --ignore-existing --delete /Volumes/My\ Book\ Thunderbolt\ Duo/FTProot/Keenhi/From_Keenhi/Dream_Tab_8_rework_tool/RecoveryTool-V1.0.0-for-DAMTAB-NV08B-1.3.7/ /Volumes/My\ Book\ Thunderbolt\ Duo/FTProot/fuhucustomer

 photo 2015-08-07_092641_zps0yequggg.jpg

System tasks
/Library/LaunchDaemons/

any user
/Library/LaunchAgents/

only you
~/Library/LaunchAgents/

##################################################

Default OSX FTPD not enable log

vi first

vi /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.ftpserver.plist

like this (Add -L and logfile name and location

 photo 2015-08-16_160901_zpstkup4xqi.jpg  

restart ftpd and tail then you can see the log.

Thu Aug 20 03:59:36 2015 1 61.149.198.208 41196 /Beijing/nabi x2/QualcommDriver/Step1_SP_Drivers_v1.4/usb/fre/Windows7/qcmdm.inf b _ o r beijing FTP 0 * c
Thu Aug 20 03:59:36 2015 1 61.149.198.208 80150 /Beijing/nabi x2/QualcommDriver/Step1_SP_Drivers_v1.4/usb/fre/Windows7/qcser.cat b _ o r beijing FTP 0 * c
Thu Aug 20 03:59:37 2015 1 61.149.198.208 97347 /Beijing/nabi x2/QualcommDriver/Step1_SP_Drivers_v1.4/usb/fre/Windows7/qcser.inf b _ o r beijing FTP 0 * c
Thu Aug 20 03:59:38 2015 1 61.149.198.208 79248 /Beijing/nabi x2/QualcommDriver/Step1_SP_Drivers_v1.4/usb/fre/Windows7/qcwwan.cat b _ o r beijing FTP 0 * c
Thu Aug 20 03:59:39 2015 1 61.149.198.208 64542 /Beijing/nabi x2/QualcommDriver/Step1_SP_Drivers_v1.4/usb/fre/Windows7/qcwwan.inf b _ o r beijing FTP 0 * c

In general, the log only have 'download' record, if you want deatil, use -d (debug mode)

vi /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.ftpserver.plist
<string>-d</string>

modify to you want path

vi /etc/asl.conf
# ftpd verbose logging
? [= Facility ftp] [<= Level debug] file /var/log/ftpdv.log

Finish.

Aug 21 15:16:17 dev.fuhu.tw ftpd[313] <Debug>: command: QUIT
Aug 21 15:16:17 dev.fuhu.tw ftpd[313] <Debug>: <--- 221 Thank you for using the FTP service on 192.168.1.7.
Aug 21 15:18:33 dev.fuhu.tw ftpd[546] <Info>: connection from 192.168.1.1 to 192.168.1.7
Aug 21 15:18:33 dev.fuhu.tw ftpd[546] <Debug>: <--- 220 192.168.1.7 FTP server (tnftpd 20100324+GSSAPI) ready.
Aug 21 15:18:33 dev.fuhu.tw ftpd[546] <Debug>: command: QUIT
Aug 21 15:18:33 dev.fuhu.tw ftpd[546] <Debug>: <--- 221 Thank you for using the FTP service on 192.168.1.7.
Aug 21 15:21:18 dev.fuhu.tw ftpd[738] <Info>: connection from 192.168.1.16 to 192.168.1.7
Aug 21 15:21:18 dev.fuhu.tw ftpd[738] <Debug>: <--- 220 192.168.1.7 FTP server (tnftpd 20100324+GSSAPI) ready.
Aug 21 15:21:18 dev.fuhu.tw ftpd[738] <Debug>: command: QUIT
Aug 21 15:21:18 dev.fuhu.tw ftpd[738] <Debug>: <--- 221 Thank you for using the FTP service on 192.168.1.7.