I want to create a Linux script to force logoff users after a fix time say 60 mins. How do i write a script in linux? I have been writing small batch programs in Windows. But i am totally new to linux. Any Help? Thanks in advance...
I want to create a Linux script to force logoff users after a fix time say 60 mins. How do i write a script in linux? I have been writing small batch programs in Windows. But i am totally new to linux. Any Help? Thanks in advance...
This may help you... A user will log out after one hour and will get a warning when last 5 minutes are remaining...
Code:#!/bin/bash hour=1 limit_time=`expr $hour \* 60 - 300` sleep $limit_time echo "5 Minutes More for automatic logoff" sleep 300 logout exit 0
How to i make this text as a script file? How do i run it at startup with run level 5? I have no idea about this. In windows i just use to add this to startup in program files and it would do the trick. Thanks though.
Open any text editor and copy the above contents there. Now save this file without any extenstion or with .sh extension. Now save this file to /etc/init.d/ location. Then run :
Now the logoff script is added to the start up...Code:cp logoff.sh /etc/init.d ln -s /etc/init.d/logoff.sh /etc/rc.d/rc5.d/S50logoff.sh ln -s /etc/init.d/logoff.sh /etc/rc.d/rc5.d/K50logoff.sh
Bookmarks