How to copy items from one or more folders to a target folder under MAC by shell
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.How to :
2.1 under mac OS
2.2 by shelluse 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.Try to make the cp commands into one file
** try to use vi
** try to invoke a bash script file, try “.” to invokemake 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 starthere 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>