Skip to content

build a plist for managing to run a task at a designated time

Notifications You must be signed in to change notification settings

zfq212git/mac-plist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The code was developed under Python3.6. Need to pip install "requests", "bs4", and "lxml"

这个代码处理不了动态生成的网页,比如www.36kr.com

BeautifulSoup这样的parser也是有它的限制。 因为网页虽然都是基于html/css写出来的,里面灵活度很大,有些情况美丽汤这样的包也是没考虑到的。


mac-plist

build a plist for managing to run a task at a designated time

 相关命令

  1. launchctl load xxxx.plist (在命令窗口中输入,把这个任务放到苹果的定时任务队列中去)
  2. launchctl unload xxxx.plist
  3. launchctl start xxxx.plist (可以用来测试任务。这个是立即执行,不管设定的时间到了没有)
  4. launchctl stop xxxx.plist
  5. launchctl list (列出现在在定时队列里的所有任务)

深入的再说一下,其实,/Library/LaunchAgents这样的目录在mac下一般有三个,我们上面说的是当前用户的目录下的,还有两个一个在/Library/LaunchAgents另一个在/System/Library/LaunchAgents/ 如果是不管哪一个用户都要定时执行的话,就要放在 /Library/LaunchAgents这个下面


其他注意

  1. 各个代码里有绝对路径,如果路径变了,需要改下代码。

  2. chmod u+x xxx --- 如果plist里面的文件不执行,可能是要赋下“可执行”这个命令,确保执行。 'u'代表owner; 'x'代表可执行

  3. Mac plist 处理不了带空格的路径

About

build a plist for managing to run a task at a designated time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published