Gnome Terminal is X application (GUI application). If you want to run any X application from cron, just "let him know" which display you're using since
cron doesn't execute commands within your normal shell environment.
First of all detect which display is being used in your system:
The output will be something like this:
Let's assume your
DISPLAY variable is
:1, then add to your script before command with GUI application
DISPLAY=:1 variable, i.e.:
DISPLAY=:1 gnome-terminal -x sh -c 'zenity --info --text="Msg1" --title="Text1..." --timeout=10;<some_command>;zenity --info --text="Msg2" --title="Text2..." --timeout=10;<some_command>;zenity --info --text="Msg3" --title="Reboot..." --timeout=10;sleep 1; exec bash'
cron there is another possibility in CentOS to run a something once at system startup -
rc-local service mechanism. Create (if it isn't created yet) file:
with the content:
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
Put to the file all of the commands you wish to execute at startup.
rc.local file executable:
chmod +x /etc/rc.d/rc.local
rc-local service and start it:
systemctl enable rc-local
systemctl start rc-local
Check if the service is running properly:
systemctl status rc-local