|1. crontab is used to schedule jobs that are executed automatically by cron on a regular basis. It's time-based, not event-based.|
2. For login, use /etc/profile, $HOME/.profile, ... depending on the login shell in /etc/passwd.
3. For logout, you may try to create a customed shell(s) to include atexit:
int atexit(void (*func)(void));