I would appreciate advice on why a script would run fine when the script is launched from a terminal command line, but some commands in the script seemingly do not run when the script is scheduled using the "at" command (and advice on how to get it to run correctly when scheduled). The script (named "open_browser.sh") is intended to open a browser at a scheduled time as follows:
#!bin/bash
#script filename: "~/Desktop/open_browser.sh"
#write to log file to verify script is running
echo "Starting open_browser.sh"
#set URL for browser
STRING = "https://news.google.com/"
#open browser - try with Firefox and Chromium
#firefox $STRING
chromium-browser $STRING
#write to log file to verify script finishes
echo "Ending open_browser.sh"
#end of script
When I run the script from a terminal command line using "./~/Desktop/open_browser.sh > log_file", the script opens the selected browser in a visible (foreground) window and writes the echo statements to the log file. When I schedule the script with the "at" command, it opens the log file and writes all echo messages, but it does not open any visible browser window. I scheduled the script using "at" as follows:
$ at now + 1 min
at> ./~/Desktop/open_browser.sh > log_file
I would be grateful for any insight as to why the script would open a browser when executed from the command line but seemingly not when scheduled using the "at" command.
For additional information, my installation has the default "at" deny file (/etc/at.deny
). I did not see any at.allow file.
Thanks in advance.
{}
at the formatting tools for this ;)./~/Desktop/open_browser.sh
is not a valid command. Use a full path instead of a~
. The~
is a BASH addition evaluated when executing it using bash.at
probably does not use bash or it it does it does not evaluate the~
If that is the solution feel free to comment so I can post it OR make the answer yourself and accept that answer :)chromium-browser
runs in a shell but needs a graphical display. You don't specify one, whereas you may have many. Your default display is called:0
. You also need to specify the full path to each executable. Try replacing the command byDISPLAY=:0 /usr/bin/chromium-browser $string
.