Home >Backend Development >PHP Tutorial >php实现定时创办指定大小文件脚本

php实现定时创办指定大小文件脚本

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:22:521197browse

php实现定时创建指定大小文件脚本

公司业务主要做数据备份(支持文件增量备份),因此在测试时,需要定时生成新文件,测试业务运作是否正常。

将以下脚本文件加入crontab,即可实现定时生成新文件。脚本的原理主要是使用dd指令创建指定大小的文件。

<?php $timestamp = time();    $id = uniqid();    $filename = "/tmp/{$timestamp}.img";    $cmd = "dd if=/dev/zero of=$filename bs=4m count=5; echo $id >> {$filename}";    exec($cmd, $ret, $output);?>



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn