-2

When I open gnome-terminal, instead of presenting me with my default Bash shell, it shows:

sh-4.4$

This began happening since I added DISPLAY=:0 to my crontab -e file which now looks as follows:

DISPLAY=:0

0 0,6,12,18 * * * /usr/bin/gnome-terminal -e /home/orschiro/bin/updates.sh
0 0,6,12,18 * * * /usr/bin/gnome-terminal -e /home/orschiro/bin/rclone.sh

And also of interest:

sh-4.4$ ls -l /bin/sh
lrwxrwxrwx. 1 root root 4 18. Jun 10:30 /bin/sh -> bash

enter image description here

migrated from askubuntu.com Jul 4 '18 at 13:54

This question came from our site for Ubuntu users and developers.

  • Please edit and add the output of grep $(whoami) /etc/passwd and cat ~/.bashrc using the formatting tools. – dessert Jul 4 '18 at 12:03
  • 1
    This is your default bash shell. Probably you have tinkered with PS1 in .bashrc or .profile. – Soren A Jul 4 '18 at 12:11
  • 2
    I think you are right. See my edits. I am on Fedora 28. Maybe that's the default symlinked behaviour? – orschiro Jul 4 '18 at 12:40
  • 4
    So, this isn't about Ubuntu at all then? – steeldriver Jul 4 '18 at 12:41
  • 4
    Also, why, oh why, do you run the scripts in a terminal emulator from your crontab. That's totally unnecessary. – Kusalananda Jul 4 '18 at 14:18
1

I'm assuming this is the gnome-terminal started from your cronjob.

There is absolutely no need to run the cronjob scripts inside gnome-terminal. Doing so would mean that the jobs would fail if gnome-terminal could not be opened (which would probably happen if you weren't using the desktop at the time).

Just use

0 0,6,12,18 * * * "$HOME"/bin/updates.sh
0 0,6,12,18 * * * "$HOME"/bin/rclone.sh

Any output from the scripts will be emailed to you, assuming local email delivery was enabled. To save the output to a log file, use a redirection:

0 0,6,12,18 * * * "$HOME"/bin/updates.sh >>"$HOME"/updates.log"
0 0,6,12,18 * * * "$HOME"/bin/rclone.sh  >>"$HOME"/rclone.log"

The environment that the cronjobs are running in is different from the one you usually have when logged in through a graphical desktop environment. For one thing, your default shell may not be set in the SHELL environment variable, which is why gnome-terminal starts /bin/sh instead of bash (sh is bash on your system, but runs in POSIX compatibility mode when invoked as sh).

When logged in on the graphical desktop environment, opening gnome-terminal as usual would give you your default shell. If it doesn't, it's because there's a gnome-terminal-server process running which was started by the cron jobs. Terminate this process by either rebooting or by using pkill -f gnome-terminal-server.

See also the comment posted by JdeBP below.

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.