<?php
$work_dir="/mnt/tnt";
$record_per=1*31*24*3600;
// scaning directrory for get list of directries
$arr_dir=scandir($work_dir);
$now=date("Ymd",time());
$old=date("Ymd",time()-$record_per);
$is_current=FALSE;
foreach ($arr_dir as $v)
{
if ($v==$now) {$is_current=TRUE;}
if ($v<$old && $v!="." && $v!="..") {
exec("rm -r ".$work_dir."/".$v);
}
}
// Create dirrectory if is apsent
if (!$is_current){mkdir($work_dir."/".$now);}
$hh=date("Ymd-H", time());
$command="killall vlc";
exec($command);
$command="sudo -u username cvlc --daemon udp://@238.1.1.10:1234 --sout 'standard{mux=\"mov\",dst=\"".$work_dir."/".$now."/tnt-".$hh.".mov\"}' ";
exec($command);
?>
Под рутом не работает, поэтому создан пользователь, в скрипте отображается как username.