0

I'm extremely new to Linux style computing. Please keep that in mind.

I figured out how to write a script for the calendar to pop up in the terminal.

!/bin/bash
Shell Scrip to display current date, calendar, and number of users

echo "Today is $(date)"

echo ""

echo "Calendar : "

cal

Super simple stuff.

Now, I want to add this to some type of startup. I want the terminal to pop up when I log into my computer every day.

I've tried System -> Preferences -> Startup Applications Then I click on add. I have no idea what to put in the command box.

I've also tried /etc/init and writing a script in there. Did something wrong there. Not sure what.

I have no idea how to use gnome.

I can't sudo into my box due to not having permission and I don't have upstart.

I'm using CentOS

Any help would be appreciated.

  • gnome-terminal -x bash -c 'cal -3; exec bash' – Panther Mar 1 '16 at 14:39
1

To open a terminal on startup, add the following line to the end of ~/.bash_profile

gnome-terminal &

To run your script when a gnome-terminal opens, add the following line to the end of ~/.bashrc

/path/to/script.sh

.bash_profile runs when your user logs in, .bashrc runs whenever a terminal is opened. gnome-terminal is the command to open a new terminal app in gnome, the & means to run it in the background (so your .bash_profile doesn't wait for the terminal to be closed before executing any other commands in it).

If either of these files don't exist you can copy a template for them from /etc/skel/ or just make them with only the lines you want.

Also, as a side note, /etc/init.d/ is where the system used to start services (now CentOS/RHEL use /etc/systemd/). Pretty much everything in /etc/ is used as service configuration, what to do and how to do them when the machine starts up.

  • gnome-terminal will exit unless you call bash. I would add "cal -3" to .bashrc and simply open a terminal. – Panther Mar 1 '16 at 14:45
  • @bodhi.zazen I'm working from RHEL right now, and I tried adding gnome-terminal & to my .bash_profile and it worked no problem. Considering CentOS is just a branch of RHEL without support I'm pretty confident it would work. Adding the command onto it could be useful though to make sure the script is only run at first login. – Centimane Mar 1 '16 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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