You are not logged in.

#1 2021-05-26 07:11:41

linz827
Member
Registered: 2021-05-26
Posts: 2

[SOLVED] Script won't launch terminal in cron

Hello

I've been using a simple bash script to check if a process is running and relaunch (because it crashes when my internet goes out periodically).

The script works perfectly fine when I call it manually, but when I run it through crontab it doesn't launch terminator. The part that logs the timestamp of the relaunch works though so the cron timer is working I think.

Can someone point me in the right direction here please? I removed the logging part trying to fault find so this is the script now. Do I need to change a permission or something to allow cronie to launch a terminal?

SHELL=/bin/bash

result=`ps -ef | grep -i "process" | grep -v "grep" | wc -l`

if [ $result -ge 1 ]
   then
	echo  Status: OK
	
   else
	exec terminator -x "/home/user/Downloads/process"

fi

Last edited by linz827 (2021-05-26 08:58:41)

Offline

#2 2021-05-26 07:47:58

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Script won't launch terminal in cron


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2021-05-26 08:55:40

linz827
Member
Registered: 2021-05-26
Posts: 2

Re: [SOLVED] Script won't launch terminal in cron

Thank you very much sir. I didn't realize I was launching an X.org application. My script was overly complex too I've realized but it's working now. Thanks for the pointer.

#!/bin/bash

if pgrep -x "process" > /dev/null; 
   then
	echo Process Status: OK
   else
	exec terminator -e "process" && date >> /home/user/scripts/logs
fi

Last edited by linz827 (2021-05-26 09:03:20)

Offline

Board footer

Powered by FluxBB