3

Actually i want to run my shell script at every time when a user login as well as at boot. i have tried using using crontab but it runs only at boot not at every login.so please tell me how to do this.

#crontab -e
@reboot  /home/user/test.sh
HBruijn
  • 72,524
  • 21
  • 127
  • 192
pawan
  • 31
  • 1
  • 1
  • 2

1 Answers1

6

You can add your script in ~/.bash_profile where ~ represents the homedir of the user for which running the script is intended.

chicks
  • 3,639
  • 10
  • 26
  • 36
Alex
  • 330
  • 3
  • 8
  • 7
    That will work, as long as users don't change their shell, and/or don't edit their personal .bash_profiles. Better would be in in the system default `/etc/profile` or better still in an include such as `/etc/profile.d/local.sh` – HBruijn Jun 07 '16 at 11:24