What is the suggested way to cron-automate ZODB pa

2019-04-18 08:23发布

Looking at plone.org to find a way to periodically pack my instance's ZODB I could only find http://plone.org/documentation/faq/how-do-i-pack-the-zodb that doesn't talk about automated packs, but just manually initiated ones.

I know I can simulate the manual pack with wget or curl, but I'd like to know if that is the best practice in use for production sites.

7条回答
一纸荒年 Trace。
2楼-- · 2019-04-18 09:03

For a python/urllib solution, see: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/MaintainingZope.stx

#!/usr/bin/python
import sys, urllib
host = sys.argv[1]
days = sys.argv[2]
url = "%s/Control_Panel/Database/manage_pack?days:float=%s" % \
      (host, days)
try: 
    f = urllib.urlopen(url).read()
except IOError:
    print "Cannot open URL %s, aborting" % url
print "Successfully packed ZODB on host %s" % host
查看更多
登录 后发表回答