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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.