I have a problem trying change date in rpi from php. If I write:
shell_exec('sudo date --set="15 NOV 2015 12:43:10"');
I don't get any feedback, output is ""
, but if I execute
shell_exec('date --set="15 NOV 2015 12:43:10"');
I recived
15 NOV 2015 12:43:10
as output but nothing change in rpi
I added www-data to sudoers with visudo command, and add
www-data ALL=(ALL) NOPASSWD: ALL
but it didn't worked.
I've tried
chmod 777 /bin/date,
nothing.. I try make .sh file with command and run with and without sudo.. same result.
Any idea? Thanks to all!
PS.Sorry for my english
我解决了我的问题...使用命令adduser www-data sudo
将其添加到sudo组中并重新执行我的第一个直观的cmd sudo date --set
...运行正常!
<?php
$sys_date = date("Y-m-d",strtotime("2015-12-02"));
$sys_time ="08:00:00";
$sys_datetime = $sys_date." ".$sys_time;
$sys_datetime =strtotime($sys_datetime);
$date = gmdate('D M d H:i:s e Y', $sys_datetime);
shell_exec("sudo date -s \"$date\"");
?>
works for me..........
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.