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

WBOY
Release: 2016-06-13 12:22:52
Original
1142 people have browsed it

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);?>
Copy after login



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template