-1

Debian stretch user here. I wanted a screen flash every ten minutes. After trying a couple of alternatives (includeing xrefresh) I decided to use sct. It works in shell but does not work with cron.

This works:

sct 2000

The script: (named colrefr)

#!/bin/bash
PATH=/usr/bin
sct 2000; sleep 3; sct

Cron: (pgrep cron shows cron is running)

* * * * * /home/user/folder/colrefr

(once every minute until debugging is successful)

I have mitigated the usual gotchas - newline after last command, setting PATH in the script, no dots in file name, etcetera.

$ which sct
/usr/bin/sct

$ which sleep
/bin/sleep/

-

$ sudo tail -f /var/log/syslog
Oct 16 16:00:01 user CRON[29060]: (user) CMD (/home/user/folder/colrefr )
Oct 16 16:00:01 user kernel: [229206.201351] sct[29062]: segfault at e0 ip 000055dca79aa8cd sp 00007ffd9dfc6220 error 4 in sct[55dca79aa000+2000]
Oct 16 16:00:01 user kernel: [229206.201366] Code: 17 20 00 66 90 ff 25 4a 17 20 00 66 90 41 57 41 56 41 55 41 54 55 53 89 fb 31 ff 48 89 f5 48 83 ec 38 e8 ae ff ff ff 49 89 c4 <48> 63 80 e0 00 00 00 4c 89 e7 48 c1 e0 07 49 03 84 24 e8 00 00 00 
Oct 16 16:00:01 user kernel: [229206.209280] sct[29064]: segfault at e0 ip 000055dcdd3268cd sp 00007ffdf60c9e40 error 4 in sct[55dcdd326000+2000]
Oct 16 16:00:01 user kernel: [229206.209295] Code: 17 20 00 66 90 ff 25 4a 17 20 00 66 90 41 57 41 56 41 55 41 54 55 53 89 fb 31 ff 48 89 f5 48 83 ec 38 e8 ae ff ff ff 49 89 c4 <48> 63 80 e0 00 00 00 4c 89 e7 48 c1 e0 07 49 03 84 24 e8 00 00 00 

I have three other cronjobs and they all work.

It runs without a hitch in shell.

2

This is a combination of two things:

  1. You have not told the program where your X server is.
  2. M. Unangst's program does no error checking and handling at all.

The program needs to inherit a DISPLAY environment variable, specified in your crontab or in a wrapper script, to tell it where the X server display that you want to adjust is. The segmentation fault that you are seeing is its failure mode if it is not told that.

You might like to report this as a bug.

You happen to have a DISPLAY variable in the environment of the shell that you are using, probably because you are using a GUI terminal emulator. If you had logged on in a non-GUI environment, such as a kernel/user virtual terminal, a real terminal, or a SSH session without X11 forwarding, you would have seen this same behaviour when you invoked the program interactively, too.

% DISPLAY= sct
zsh: segmentation fault  DISPLAY= sct
%

Further reading

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.