I have the shell script which opens Firefox and launches macros in it (I use a Firefox add-on called Imacros to create macros). The content of my shell script named house.sh is like that:  firefox imacros://run/?m=house.iim   And I created a scheduled job via crontab -e to run that script hourly every day:  47 * * * * /home/meerim/bin/house.sh   But nothing happened (Firefox didn't open). Then I tried this:  47 * * * * env DISPLAY=:0.0 /home/meerim/bin/house.sh   But it didn't solve the problem. So how should I fix it? My house.sh script works properly when I run it from terminal.
1867
Once upon a time,  DISPLAY=:0.0 totem /path/to/movie.avi   after ssh 'ing into my desktop from my laptop would cause totem to play movie.avi on my desktop.  Now it gives the error:   No protocol specified Cannot open display:    I reinstalled Debian squeeze when it went stable on both computers, and I guess I broke the config.   I've googled on this, and cannot for the life of me figure out what I'm supposed to be doing.   (VLC has an HTTP interface that works, but it isn't as convenient as ssh.)  The same problem arises when I try to run this from a cron job.
74016
Trying to set up a daily cron job to shut down a server.   One source suggests editing /etc/crontab  Another suggests crontab -e (with sudo)  I tried the latter, and my process did not run (if I recall, it was 30 23 * * * shutdown -h)   I also note that in the nano editor, it was working on a .tmp file? (top of nano says: /tmp/crontab.9zeTNt/crontab )  What is going on? How can I fix this?
101452
I would like to write a set of shell scripts which would execute smoothly on Mac disregarding where they are called from.  I am currently struggling about how to implement this.  On windows, I could write three batch scripts  A.bat in folder A B.bat in folder Subfolder, which is subfolder of A and which path is A/Subfolder C.bat in folder Subfolder, which is subfolder of A and which path is A/Subfolder  In A.bat I could write  call Subfolder/B.bat   in B.Bat I could write  call C.bat   and both scripts A and B would execute successfully.  On Mac, however, I have to prepend ./ to every script so that it is recognized as script.  So when I write in a.sh code:  Subfolder/b.sh   and then in b.sh code  ./c.sh   when I execute ./b.sh from terminal it is executed successfully.  However, when I execute ./a.sh from a parent folder in terminal, it fails with error   ./a.sh Subfolder/b.sh: line 1: ./c.sh: No such file or directory    Is this possible on Mac to write a code in b.sh which would execute disregarding if it is called from the current folder or from the parent folder?
120554
I am trying to run a simple echo script via crontab. I set that to run every minute, but it doesn't give output on shell screen. However, it runs fine when I run the script independently.   Script  #!/bin/bash echo "Test Script"   Crontab entry:  root@example-server ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/     # For details see man 4 crontabs  # Example of job definition: # .---------------- minute (0 - 59) # |  .------------- hour (0 - 23) # |  |  .---------- day of month (1 - 31) # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # |  |  |  |  | # *  *  *  *  * user-name command to be executed   *  *  *  *  * root /root/test.sh
101172
I have a program that prints some output that I would like to pop up on my terminal once every hour during the workday.  $ crontab -l 0 07-17 * * * /home/dat/scripts/cron.out   syslog reports the following:   (dat) CMD (/home/dat/scripts/cron.exe) Jun 18 12:02:01 picard CRON[10848]: (CRON) info (No MTA installed, discarding output)   What am I missing?
6981
I wrote this script, but it doesn't work:  #! /bin/bash cront=$(crontab -e) echo 00 23 * * 5 tar -cpzf /var/backup.tar.gz /home/$USER &gt;&gt; $cront   How can I add a cronjob using a script?
25271
I'm trying to create some webapps to use with Firefox. I got an tutorial from Canonical () and I didn't understand one thing, maybe someone could help me.  I have to run the following script in Web Console:  // ==UserScript== // @name          tumblr-unity-integration // @include       https://tumblr.com/dashboard // @version       @VERSION@ // @author        WebApps Team // @require       utils.js // ==/UserScript==  window.Unity = external.getUnityObject(1.0);  Unity.init({ name: "Tumblr",             iconUrl: "icon://Tumblr",             onInit: null });   Everything is fine, it created the icon launcher and work with alt+tab. That enough for me by now, but, if I close the windows, the launcher icon that I created before stop working (I mean, it open the site, but doesn't work like other webapp and doesn't show in alt+tab too). Maybe I have to run this script automatically every time I enter on that site (In this example, Tumblr). How can I do that?  Thanks,
77127
I can seem to run scripts (.sh) with and without them being set as executable. So where exactly this matters?
93422
I tried to set up a root cron job to run a Bash script as root, to run at minute 7,37, every hour, every day of month, every month. This script is located in /usr/bin and named tunlrupdate.sh. It updates the DNS of Tunlr.  $ ls -l /usr/bin/tunlrupdate.sh  -rwxr-xr-x 1 root root 2133 Sep 24 15:42 /usr/bin/tunlrupdate.sh   This Bash script is available .  When invoked the script writes what's happening in a log located in /var/log/tunlr.log  To add this root cron job I used the standard for root's crontab  sudo crontab -e   And inserted these 2 lines at the end. I expect cron to run the script as root.  # check for updated Tunlr DNS every 30 minutes at the hour + 7 mn and hour + 37 mn 07,37 * * * * root /usr/bin/tunlrupdate.sh   A later command sudo crontab -l confirmed that the cron job has been inserted.  I did reboot Ubuntu and was checking in the log file if the cron job was launched properly. However there is nothing in the logfile /var/log/tunlr.log meaning the job was never successfully launched.  I did check that if I run the script from the command line  sudo /usr/bin/tunlrupdate.sh   then the logfile is updated accordingly.  Why is this cron job not running as planned in my system?  UPDATE 1 : All the proposed solutions so far do not work. I thank Olli for a CLI to list the system log sudo grep CRON /var/log/syslog. However I did get a CRON error  CRON[13092]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] &amp;&amp; [ -d /var/lib/php5 ] &amp;&amp; find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php /maxlifetime) ! -execdir fuser -s {} 2&gt;/dev/null \; -delete)   with the suggested PATH= insertion &amp; use of absolute path from root for functions in the script or without this suggested solutions here. I still get this error.  After some searching I pinpointed the error in the file /usr/lib/php5/maxlifetime as is explained : Change #!/bin/sh -e --&gt; #!/bin/sh -x  Then listing the CRON error log in my system  sudo grep CRON /var/log/syslog Feb 11 18:07:01 Marius-PC CRON[14067]: (root) CMD (root /usr/bin/tunlrupdate.sh) Feb 11 18:07:01 Marius-PC CRON[14066]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)   I still don't get the bash script executing. This time no error is shown in the log. To get assurance this was not the content of the script I reduced the script to the following 3 lines:  #!/bin/bash LOGFILE=/var/log/tunlr.log echo $LOGFILE &gt;&gt; $LOGFILE   I still don't get the cron job through. Nothing is written in the log file. So even may be an empty script will not run in cron ? I don't get it. I am know trying a script reduced to these 2 lines:  #!/bin/bash exit 0   And still the same error log. The cron script does not go through ...
89141
Shell Type:  &gt;echo $SHELL /bin/ksh   Cronjob :   15 * * * * /bin/ksh /wls_domains/resMGT/logs/bea/wlr3queuetransaction.sh &gt; /wls_domains/resMGT/logs/bea/data/script.log  The script is as below:  ##log files and lookup file "wlr3queue.txt" are in the same path of the script ##/wls_domains/resMGT/logs/bea/wlr3queuetransaction.sh  Script :  #!/bin/ksh  dt=`date +%Y-%m-%d` xy=`date|awk '{print $4}'|awk -F":" '{print $1}'` yz=`expr $xy - 1` if [ $yz -le 9 ] then yz=0$yz fi  if [ $xy -gt 0 ] then  for i in `cat wlr3queue.txt` do  sum=0  count=`gzgrep -i "$dt" admin_resMGT_access.log* | grep "$yz:[0-5][0-9]" | grep "$i" | wc -l`  if [ $count -gt 0 ] then name=`echo $i | cut -d'/' -f3`  gzgrep -i "$dt" admin_resMGT_access.log* | grep "$yz:[0-5][0-9]" | grep "$i" | awk '{print $8}' &gt; consumed_time.txt  for j in `cat consumed_time.txt` do j_ms=`echo "$j * 1000" | bc` echo $j_ms &gt;&gt; consumed_ms_time.txt done  for k in `cat consumed_ms_time.txt` do sum=`echo "$sum + $k" | bc` done  avg=`echo "scale=2; ($sum/$count) "| bc`  min=`cat consumed_ms_time.txt | sort -n | head -1`  max=`cat consumed_ms_time.txt | sort -n | tail -1`  else  avg=0  min=0  max=0  fi ( echo $yz","$count","$avg","$min","$max )&gt;&gt;/wls_domains/resMGT/logs/bea/data/$name$dt.csv   rm -f consumed_ms_time.txt  done  else  echo "script won't execute at this hour" &gt; temp.txt  fi   I have executed the following commands and the script ran successfully.  ./wlr3queuetransaction.sh sh -x wlr3queuetransaction.sh /bin/ksh /wls_domains/resMGT/logs/bea/wlr3queuetransaction.sh  /bin/ksh/ wlr3queuetransaction.sh.   How to debug? What to do?
17920
I am looking for a simple and generic solution that would allow you to execute any script or application in crontab and prevent it from running twice.  The solution should be independent on the executed command.  I assume it should look like lock &amp;&amp; (command ; unlock) where lock will return false if there was another lock.  The second part would be like if it acquired the lock, run command and unlock after command is executed, even if it returns error.
109915
I have a CRONTAB entry as below. Can someone tell me what the below statement is exactly doing?  1 0 * * * /vol01/sites/provisioning/MNMS/45627/45627.sh1 &gt;&gt; /vol01/sites/provisioning/MNMS/45627/output/cron.log 2&gt;&amp;1
19648
abhigenie92@ubuntu:~$ (sleep 2; echo $BASH_SUBSHELL ;sleep 2) 1 abhigenie92@ubuntu:~$ (sleep 2; echo $BASH_SUBSHELL ;sleep 2)&amp; [1] 3297 abhigenie92@ubuntu:~$ 1  [1]+  Done                    ( sleep 2; echo $BASH_SUBSHELL; sleep 2 )   What happens when launch it as a background process, why don't I get the prompt back and I have to press Enter? In both cases it launches a child shell.
75140
I have the following shell script that sums up all the arguments passed to it (space separated):  sum=0 for arg in "$@"; do     (( sum += arg )) done echo $sum   I have saved it as SumAll.sh. So, its supposed to function as follows:  sh SumAll.sh 2 4 6 8 20   or  bash SumAll.sh 1 -2 3 -3 -1   Both work on my local machine (MacBook), but when I try the same in a linux server, running the script with bash works, but with sh does not work. I get the following error:  sum: '+=': No such file or directory sum: arg: No such file or directory   Why is that? And how do I fix it?
43827
The following crontab does not work:  # TEST LINE DOES DOT RUN */1 * * * * /bin/echo 'test '`/bin/date +%Y-%m-%d` &gt;&gt; /tmp/test   I also tried starting it with:  SHELL=/bin/bash   Update: I thought the backtick characters ` were the villains, but as the answer below clarifies the percentage % was the culprit!
9449
I'm trying to write a shell script that, when run, will set some environment variables that will stay set in the caller's shell.  setenv FOO foo   in csh/tcsh, or  export FOO=foo   in sh/bash only set it during the script's execution.  I already know that   source myscript   will run the commands of the script rather than launching a new shell, and that can result in setting the "caller's" environment.  But here's the rub:  I want this script to be callable from either bash or csh.  In other words, I want users of either shell to be able to run my script and have their shell's environment changed.  So 'source' won't work for me, since a user running csh can't source a bash script, and a user running bash can't source a csh script.  Is there any reasonable solution that doesn't involve having to write and maintain TWO versions on the script?
91263
Why does the ps shows a process even if it is not running. While Firefox is running:  $ echo $(ps aux | awk  '/firefox/{print $2}') 5964 6041   But when Firefox is not running, I tried to run the same command. It showed  a different PID each time.  I tried grepping it:  $ ps aux | grep firefox greenpa+  6056  0.0  0.0  15956   948 pts/11   S+   09:29   0:00 grep --color=auto firefox   What does it mean?