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

1 Answer 1


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

  • 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
    Commented Jun 7, 2016 at 11:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .