The terminal is a window, which a cronjob doesn't support. So you could export the display in your dash and maybe even your XAuthority - but why?
Cron runs in a "headless" environment, so it doesn't know anything about how to open a window.
What you could to - if you need a terminal running - is to install tmux. Cron could create and execute a tmux session which you could access any time.
--EDIT --
I'm not sure, but tmux doesn't work this way. Below an example that works on any machine, that has systemd installed:
[Unit]
Description=Python Example
[Service]
ExecStart=/usr/bin/python3 /root/bin/somePath/MyPythonProgram.py
StandardOutput=journal
[Install]
WantedBy=multi-user.target
But this is not interactive. You would have to enable and start the service once.
Another example with tmux (that I couldn't get started with systemd yet):
#!/bin/bash
SESSION=rec
#get the current directory
DIR="$(dirname "$0")"
tmux start-server
# if the session is already running, just attach to it.
tmux has-session -t $SESSION
if [ $? -eq 0 ]; then
echo "Session $SESSION already exists. Attaching."
sleep 1
tmux attach -t $SESSION
exit 0;
fi
create a new session, named $SESSION, and detach from it
tmux new-session -d -s $SESSION -n 'Daemon'
split into 2 panes vertically window 0
tmux split-window -v -t 0
tmux new-window -n 'Web Server'
#select the only window ...
tmux select-window -t 0
#issue the commands for pane 0 and 1
tmux send-keys -t 0 $DIR/startDaemon.sh C-m
tmux send-keys -t 1 $DIR/startWebServer.sh C-m
#make the top pane the selected one...
tmux select-pane -t 0
#and attach the session
tmux a
This runs two sessions in tmux.
* * * * *
to@reboot
, Also usesudo crontab -e
instead ofcrontab -e
which is your regular user ID. – WinEunuuchs2Unix Jun 14 '20 at 21:43