Easiest way is to stick a reference add a cronjob which references:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
You're doing it wrong, he wants to lock his computer..
... Let do it properly. (this is for fun btw)
Go to http://www.maplin.co...-type-spst-2445
and buy a SPST.
Open the Computer case, and locate the power button. Cut the ONE of the wires. Drill a hole big enough for SPST and install in place. Run the cut wire from the power button one of the pins on the SPST and solder it on. Then using the cable that comes from the motherboard, solder that to the other pin on the SPST
note: If the wire isn't long enough for where you want to install it, you can you can order some more or just cut up an Ethernet cable and use the wire from the cords in there.
Now, you can actually use the SPST to lock the PC. Turn the PC off and you'll need to set the key to unlock it to turn it back on.
What you're doing here using a lockable switch. The switch (SPST) needs to be in the On position (unlocked) to allow the PC's momentary button to pass power to the motherboard when it's pressed. Without that, you can't turn the PC on without opening it up.
Later on you use the other pins hook up a robotic arm, along with an alarm clock connected to an old cell phone that you can text to lock and unlock the PC. Using an automated reminder service you can have the PC locked and unlocked automatically and you won't even need a password