0

I would appreciate any help I'm trying to run a cron which --- executes python script - that opens a terminal window and runs python script. It's a websocket script that I need to be able to monitor the out in the window.

Everything works fine when I run from a terminal window or from the pycharm emulator. But, when I run this from a cron - it errors

Unable to init server: Could not connect: Connection refused
Failed to parse arguments: Cannot open display:
import os
path = '/home/bob/scripts/'
os.chdir(path)
os.system("gnome-terminal -- python /home/bob/scripts/test.py & ")

I'm running Ubuntu 20.04 and webmin to create the cron. All other crons work fine.

Art
  • 2,836
  • 4
  • 17
  • 34
ZHBA
  • 11
  • 4
  • the first solution from here worked for me: https://askubuntu.com/questions/1108808/gnome-terminal-fails-to-start-timed-out – Ameer Helmi Oct 11 '21 at 18:11
  • @AmeerHelmi thanks I'm not understanding how the answer applies to the failure when running a cron. i apologize for my lack of understanding the applicati0on of the answer given. – ZHBA Oct 13 '21 at 17:41
  • Running in a window is not a sane or useful requirement. Run it with output to a file, or use `tmux` or `screen` if you need to attach to it interactively. – tripleee Nov 03 '21 at 05:00

1 Answers1

-1

I am unable to reply directly to your comment but what you would want to do is have the ~/term executable that was mentioned in the first solution also set in your cron. I was using .profile and it worked fine so I would envision that cron would also work well.

https://askubuntu.com/questions/1108808/gnome-terminal-fails-to-start-timed-out