简体   繁体   中英

how to enable linux support users for a certain no of hrs using php

I want to enable linux support user for 8 hours and then lock his login automatically.

Front end is built using PHP and below is what I have used ..

// Enabling Support
shell_exec("sudo passwd -u support");
// Time to Expire
$date = date("h:i:s A", strtotime('+8 hours'));
$timeat = substr($date,0,2).substr($date,9,11);
// Cron setup using 'at' command 
shell_exec("sudo at ".$timeat." -f /path/to/cron/disablesupport.php");

disablesupport.php has the below code.

//Locking Support
shell_exec("passwd -l support");

This didn't work. Please fix and help me with a solution.

Revise the PHP.ini file for custom time configuration.

For Ubuntu, the /etc/php5/apache2/php.ini file should be revised.

Change the line: session.gc_maxlifetime=28800

(28800 seconds = 8 hours)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM