Score:0

Run a sh with Xvfb display using cron?

in flag
Sid

I am trying to run a sh script using cron. This script requires a display.

I have tried:

# Xvfb display
/usr/bin/Xvfb :10 -ac -screen 0 1024x768x24 &
15 17 * * * /bin/sh /path/to/script/script.sh > /path/to/log/log.log 2>&1

Nothing happened and the log.log was not created. How do I check for errors?

Second try:

20 17 * * * <user> export DISPLAY=:10 /bin/sh /path/to/script/script.sh > /path/to/log/log.log 2>&1

Same result no log file, and I can't see whether it got executed or had issues.

hr flag
You can check for messages from cron using `journalctl -u cron.service -xe` for example. Where exactly are you placing the cron command (user's crontab? root's crontab? systemwide /etc/crontab?)
Sid avatar
in flag
Sid
@steeldriver user's crontab. I ran the command. I see that it tried to execute both times but got this error: `(ubuntu) CMD (ubuntu export DISPLAY=:10 /bin/sh /ibc.paper/twsstart.sh > /ibc.paper/lo Jun 14 17:28:01 CRON[1659]: (CRON) info (No MTA installed, discarding output)`. Not sure why the output didn't go to log file.
hr flag
Only the systemwide `/etc/crontab` needs the `<user>` field after the timespec - when you put it in a user crontab (`crontab -e` or `sudo crontab -e`) cron tries to execute the username as part of the command - which appears to be what is happening here `CMD (ubuntu ...`
Sid avatar
in flag
Sid
@steeldriver I removed the <user> `(ubuntu) CMD (export DISPLAY=:10 /bin/sh /ibc.paper/twsstart.sh > /ibc.paper/logs/cron Jun 14 18:25:01 CRON[1617]: (CRON) info (No MTA installed, discarding output)` same error am I missing a `>` where I specify log file? Thanks
hr flag
... your redirections are OK I think - the issue may be that your user can't write to `/ibc.paper/logs/` ?
Sid avatar
in flag
Sid
@steeldriver double checked that I do have permission...thinking what I could be doing wrong.
bac0n avatar
cn flag
export has the format `export name[=word]`, so it means you are trying to export the names DISPLAY, /bin/sh, /path/to/script/script.sh
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.