1

I try to run a Sikulix script but nothing happens.


crontab:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/absolute
MAILTO=""

# m h dom mon dow user  command
00 3    * * *   root    sh /usr/crons/this_script_works
10 3    1-5 * * root    /home/absolute/runsikulix -r /home/absolute/auto/test.sikuli

If I run it using this command, the script works well:

sudo /home/absolute/runsikulix -r /home/absolute/auto/test.sikuli 

Any idea?

1

You need to capture the elusive crontab output so you can see what it is complaining about.

  1. Add -x to your shebang for verbose output in your script: #!/bin/sh -x

  2. Set the cron job to execute more frequently while you troubleshoot it: */1 * * * * root /home/absolute/runsikulix -r /home/absolute/auto/test.sikuli

Crontab should be logging to /var/log/syslog by default. Run a grep CRON /var/log/syslog and check the output. If you see your job executing then you can tail -f the syslog when cron runs and see what it is complaining about.

  1. If the output is not verbose enough you can reconfigure cron to output to a log file following these instructions. This is the "proper" way to do that:

Configuring crontab to log to a file...

This should show you each step that crontab is executing so you can see where its failing. I will note that crontab's environment is pretty slim and you should be using full instead of relative paths in your script since any binaries you call out may or may not be available in your path when it runs. Crontab is funny like that. To get around this you can either add paths to your script:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

...or you can call out each binary using it's full path:

/bin/echo "say something" && /bin/which java

You can also call a user's environment inline:

0 5 * * * . /root/.profile; /home/absolute/runsikulix -r /home/absolute/auto/test.sikuli

Here is a sample script in Ruby template format that runs under root's crontab that illustrates some workarounds for dealing with the environment issues:

master-commender.erb

  • There is not a sikuli.out file in var/log/. – Ppetrelli Apr 14 '16 at 16:57
  • syslog code about it: Apr 14 18:54:01 my-user CRON[7385]: (root) CMD (/home/absolute/runsikulix -r /home/absolute/auto/test.sikuli >> /var/log/sikuli.out 2>&1) Apr 14 18:54:04 my-user org.gnome.Terminal[1098]: (gnome-terminal-server:1877): dconf-CRITICAL **: unable to create file '/run/user/1000/dconf/user': Permiso denegado. dconf will not work properly. – Ppetrelli Apr 14 '16 at 17:04
  • I tried spyderdyne solution mix with "How to start a GUI application from cron?" and after a lot of tries... I get this: <br> */1 * * * * root export DISPLAY=:0 /home/absolute/runsikulix -r /home/absolute/auto/test.sikuli >> /var/log/sikuli.out 2>&1 sikuli.out: /bin/sh: 1: export: /home/absolute/runsikulix: bad variable name – Ppetrelli Apr 15 '16 at 18:14
  • 1
    And finally it works. + */1 * * * * root export DISPLAY=:0; /home/absolute/runsikulix -r /home/absolute/auto/test.sikuli >> /var/log/sikuli.out 2>&1 sikuli.out <ul> Just I typed "xhost +" to get X permissions, I think. – Ppetrelli Apr 16 '16 at 12:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.