Running Bash script at login

This question has been asked numerous times but for some reason, none of the solutions proposed worked for me. I just want to run a simple script after the user has logged in.

Here are my attempts:

  • I have tried putting the script in /etc/init.d/ and making a symlink in /etc/rc0.d.
  • I tried scheduling it using the @reboot in crontab (crontab -e). Annoyingly, @reboot does not seem to work in Ubuntu(?). I tried this simple line@reboot echo "hi there" to no avail.
  • I tried putting it into the root's crontab(sudo crontab -e) but still nothing happened. Also a simple echo in this crontab does not work too.
  • I also tried to use the @reboot syntax suggested here (@reboot root /home/me/Desktop/script.sh)
  • Followed this and placed the path of the script in /etc/rc.local

Notes:

  • I'm using Ubuntu 14.04
  • home is mounted, but I also tried my attempts in a VM where home is not mounted
  • I only want to run the script after the user has logged in
  • Nothing fancy about the script it just echoes "hello world"

The standard location for a script that must run at login is /etc/profile. It will then run for every user (once) when they log in. The user never gets to see the output of the script, it is logged

If it is only for a specific user, it should be added to .profile in their home directory.

With login I mean when you enter your username and password.

Any errors normally show up in ~/.xsession-errors

If it has to run every time you open a terminal window, it should be added to /etc/bash.bashrc or to .bashrc in the user's home directory.

At work, I mount a number of network shares when I log in. This is done in .profile in my home directory (it needs only to be done once).

Every time I open a terminal window I get a fortune cookie. This happens because the last line in .bashrc in my home directory contains fortune.