Search code examples
phplinuxshell-execraspberry-pi2

change raspberry pi date from php


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


Solution

  • I solved my problem... after add to sudo group with command adduser www-data sudo and re-execute my first intuitive cmd sudo date --set... runs ok!!