Home > Backend Development > PHP Tutorial > PHP implements scripts to create files of specified size regularly

PHP implements scripts to create files of specified size regularly

WBOY
Release: 2016-08-08 09:21:19
Original
1259 people have browsed it

The company's business mainly does data backup (supports incremental file backup), so during testing, new files need to be generated regularly to test whether the business is operating normally.

Add the following script file to crontab to generate new files regularly. The principle of the script is mainly to use the dd command to create a file of a specified size.

<?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

The above introduces the PHP script to create a file of a specified size regularly, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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