Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
yifeng
V2EX  ›  Linux

数据自动备份求助!!!!!!!

  •  
  •   yifeng · Aug 21, 2015 · 3321 views
    This topic created in 3929 days ago, the information mentioned may be changed or developed.
    远程 linux 服务器上有一个 xml 的配置文件,需要实现的功能是数据的自动备份,并可以在本地 php 管理界面设置自动备份的定时时间。
    ---------------------------------------------------------------------------------------------------------------
    数据自动备份容易实现,怎么动态改变自动备份的定时时间,求思路。

    哪位爷能指点指点,不胜感激!!!
    2 replies    2015-08-21 13:24:54 +08:00
    9hills
        1
    9hills  
       Aug 21, 2015   ❤️ 1
    crontab ,然后用 php 管理 crontab
    pizida
        2
    pizida  
       Aug 21, 2015   ❤️ 1
    技巧:把要执行的 php 文件都放在一个 shell 里面,这个 shell 你可以根据周期命名。

    例如 conrtab_every_morning.sh ,表示每天早上执行一次
    然后该 shell 中写入要执行的 php 文件,
    [code]
    #!/bin/sh
    php -f test.php >/dev/null 2>&1
    [/code]

    这个 sh 你还可以写其他的 shell 命令,固定微每天早上执行,这样以后新文件加入即可,不用改 crontab 。

    最后编辑下定时器即可:
    30 2 * * * cd /shell/ && ./conrtab_every_morning.sh
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2871 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:19 · PVG 13:19 · LAX 22:19 · JFK 01:19
    ♥ Do have faith in what you're doing.