Hey nixcraft and welcome to my first post,
I think it's easy for you to solve and no big deal, but for me this is rather hard to accomplish as I'm pretty new to the wonderful world of linux.
The environment is a Debian 6 VM without KDE / GNOME / X11 or sth.
I'm trying to get the ability to create accounts which expire (disallow login)..let's say 3 hours after creation. The first things are no problem for me:
But the expiry date really sucks for me. The options I had were:
useradd username --no-create-home --shell /bin/false
echo username:password | chpasswd
Chage was knocked out very fast, as it only accepts dates, no hours or minutes.
I think it's better to use cron for recurring activities, but not for '1-time' use.
At seems to work like a charm, but as I want to include everything in a PHP script (don't worry, I've made my homework consulting the security. The script is limited to my and only my IP adress, also the 'server' this runs on is only a virtual machine on my PC, so security is not a big deal yet) I'd prefer to have everything wrapped in one line, not the standard procedure, which is like at now + 3 hours, > command here, STRG+D.
At seems to accept input from a file with the -f flag. But I don't want to create a file for every user, delete it and so on.
I thought about something like:
at now + 3 hours | echo 'run this command'
(Pipelined input or something, not sure about it )
But that won't work, and it was the only solution I could imagine.
Please help me to get this running ASAP, help is highly appreciated.