Plist 简述

来源:互联网 发布:搜索引擎优化规则 编辑:程序博客网 时间:2024/05/01 06:41

How to copy items from one or more folders to a target folder under MAC by shell

  1. Purpose:
    let’s say we have one or more folders that need to be copied to another folder which can be saved in the cloud server.

  2. How to :
    2.1 under mac OS
    2.2 by shell

  3. use utility cp command to copy the folder or files,
    **attention: cp will overwrite the target files no matter if the content of the source file conflicts with the target one.

  4. Try to make the cp commands into one file
    ** try to use vi
    ** try to invoke a bash script file, try “.” to invoke

  5. make that one file run in a scheduler
    ** try to use cron command
    ** the alternative in MAC OS is to use LaunchCtl which will deliver jobs to Launchd to run .
    Notes to use LaunchCtl:
    a) make the script file executable by issuing chmod +x your_scripfile
    b) make a plist file , and place it under the directory ~/Library/LaunchAgents/. So that this script would be launched each time you login. There are many other system directories you can put your plist file, you can have a detailed explanation by issuing man Lauchd.Plist. Attention, you must name your script file end in a .plist.
    c) start running the script file : launchctl start

    here is an example of plist file :

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE plist PUBLIC "-//APPLE//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0">        <dict>                <key>Label</key>                <string>files.sync</string>                <key>programarguments</key>                <array>              <string>/users/lewis/tools/syncfiles</string>                </array>                <key>StartInterval</key>                <integer>3600</integer>        </dict></plist>
0 0
原创粉丝点击