I have a program that contains two files: a python script and a shell script that downloads www.bing.com wallpaper and put it for my desktop background.  When I run this it works but it dosent work by my cron.  I have made a cronjob for that program but it dosen't work.  My cron entry is:  42 */4 * * * /home/ahmad/myBing/bingwallpaper.sh   my code:  #!/bin/bash  # Get download link and store it on downLink . downLink=$(/home/ahmad/myBing/index.py)  # Making pic name . picName=$(echo $downLink | cut -f7 -d"/")  # Set picture options # Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned picOpts="zoom"  if [ $downLink != "net is off" ] then     mkdir -p $HOME/Pictures/BingDesktopImagePython/     # Download the link by wget .     wget -O $HOME/Pictures/BingDesktopImagePython/$picName "$downLink" &amp;&gt; /dev/null     # Set the GNOME3 wallpaper     gsettings set org.gnome.desktop.background picture-uri "file://$HOME/Pictures/BingDesktopImagePython/$picName"     # Set the GNOME 3 wallpaper picture options     gsettings set org.gnome.desktop.background picture-options $picOpts else     echo -e "Net is off :(" fi  # Exit the script exit   and my python script:  #!/usr/bin/python import re import requests import BeautifulSoup import os  def getLink():     if os.uname()[0] == "Linux":         baseUrl = "http://www.bing.com"                   imgUrl = "http://www.bing.com/HPImageArchive.aspx?format=xml&amp;idx=1&amp;n=1&amp;mkt=en-US"         try:             html = requests.get(imgUrl)  # Get xml code .         except:             print ("net is off")    # it runs if net is off .         else:             soup = BeautifulSoup.BeautifulSoup(html.content)                  link = soup.find('url',text = re.compile('(.jpg)$'))    #Get first &lt;url&gt; ... &lt;/url&gt; string .             downLink = baseUrl + link   # make download link .             print (downLink)          else:         print ("Your os should be Linux.")         exit() getLink()
62703
I'm trying to change my wallpaper to a random image using Indrajith Indraprastham's suggested script here:    When I run the script from a terminal window, the bg changes just fine, but when it's run from cron, I'm mailed this error:     (process:21901): dconf-WARNING **: failed to commit changes to dconf: Error spawning command line 'dbus-launch --autolaunch=00216c114dcf433c9bb9009985d607d6 --binary-syntax --close-stderr': Child process exited with code 1   I would appreciate any suggestions.
92861
I'm trying to get execute a cron job everyday at noon but i can't get it to run. To test it i even tried something like a simple create command but it never runs, it seems as if the file isn't even used. I also can't see anything going wrong in the log.  0 12 * * * mkdir /path/to/folder   So is there something wrong with this line or should i look elsewhere?  I created the crontab as root with crontab -e
106187
I'd like to do a health check of a service by calling a specific url on it. Feels like the simplest solution would be to use cron to do the check every minute or so. In case of errors, cron sends me an email.   I tried using cUrl for this but I can't get it to output messages only on errors. If I try to direct output to /dev/null, it prints out progress report.    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100  5559  100  5559    0     0   100k      0 --:--:-- --:--:-- --:--:--  106k   I tried looking through the curl options but I just can't find anything to suit the situation where you want it to be silent on success but make noise on errors.  Is there a way to make curl do what I want or is there some other tool I should be looking at?
81580
I am trying to make a crontab that makes a new .tar file each minute every business day by using the following code:  */1 * * * 1,2,3,4,5 tar -cf /home/user/Archiv/$(date +"%Y%m%d%H%M").tar /home/user/Textverarbeitung/ -P   This doesn't work. Why?
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.
10844
I am using Arch Linux with KDE/Awesome WM. I am trying to get  notify-send to work with cron.   I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.  I am able to call notify-send interactively from the session and get notifications.  FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.  Code:  [matrix@morpheus ~]$ crontab -l * * * * *  /home/matrix/scripts/notify.sh  [matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh #!/bin/bash export DISPLAY=127.0.0.1:0.0 export XAUTHORITY=/home/matrix/.Xauthority echo "testing cron" &gt;/tmp/crontest sudo -u matrix /usr/bin/notify-send "hello" echo "now tested notify-send" &gt;&gt;/tmp/crontest  [matrix@morpheus ~]$ cat /tmp/crontest testing cron now tested notify-send  [matrix@morpheus ~]$    As you can see the echo before &amp; after notify-send worked. Also I have tried setting DISPLAY=:0.0   UPDATE: I searched a bit more and  needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute!   But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.   [matrix@morpheus ~]$ cat scripts/notify.sh #!/bin/bash export DISPLAY=127.0.0.1:0.0 export XAUTHORITY=/home/matrix/.Xauthority export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c echo "testing cron" &gt;/tmp/crontest /usr/bin/notify-send "hello" echo "now tested notify-send" &gt;&gt;/tmp/crontest   Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?
47557
I'm trying to implement a configuration mechanism that allows in a certain project to deploy through svn a cron configuration.  I immediately thougt that what I should do is cerate symlinks from /etc/cron.d/ to my project's cron file (which in turn is controlled by a vcs), but that seems to not be working.  I found some old forum messages referring that symlinks were not supported and other saying that they are. Which is it?  Is there anything else or any other good way to achieve this?
104270
I have a text file on my local machine that is generated by a daily Python script run in cron.   I would like to add a bit of code to have that file sent securely to my server over SSH.
92777
I have a backup script which I need to run at a particular time of a day so I am using cron for this task and from within cron am also trying to redirect the output of backup script to a logfile.  crontab -e  */1 * * * * /home/ranveer/backup.sh &amp;&gt;&gt; /home/ranveer/backup.log   In the above cron entry I am redirecting both stderr and stdout to a log file.  The above cron job executes fine according to syslog  and it performs the task mentioned in the backup.sh file but it doesn't write anything to the log file.  /var/log/syslog  Oct 19 20:26:01 ranveer CRON[15214]: (ranveer) CMD (/home/ranveer/backup.sh &amp;&gt;&gt; /home/ranveer/backup.log)   When I run the script from cli it works as required and output is written to a log file  ranveer@ranveer:~$ ./backup.sh &amp;&gt;&gt; backup.log  ranveer@ranveer:~$ cat backup.log Fri Oct 19 20:28:01 IST 2012 successfully copied testdir test.txt successfully copied ------------------------------------------------------------------------------------- ranveer@ranveer:~$    So, why the output of file is not getting redirected to the file from within cron.
13127
I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this.  How do I add Cron jobs in Ubuntu?
36995
After doing a "sudo su -" on an Ubuntu 12.04 notebook I did a "crontab -e", added this:   * * * * * env DISPLAY=:0.0 /usr/bin/gnome-calculator   and waited for minutes. Nothing Happened. I don't have any external monitors and if I run this command "env DISPLAY=:0.0 /usr/bin/gnome-calculator" in the terminal, it just works. But not from cron. Why?   The syslog only contains this:   May 24 14:37:01 localhost cron[1227]: (root) RELOAD (crontabs/root) May 24 14:37:01 localhost CRON[16432]: (root) CMD (env DISPLAY=:0.0 /usr/bin/gnome-calculator )   And I already tried an "xhost +localhost".   [root@NOTEBOOK /var/log] xhost access control enabled, only authorized clients can connect INET:localhost.localdomain SI:localuser:USERNAME [root@NOTEBOOK /var/log]    So the solution for another question like this on askubunut didn't worked.
16152
I want to edit my crontab file to schedule a script. Where do I find it?
92382
I have capped data which is essentially free between midnight and 5am. As a result, I would like to set Ubuntu to automatically download updates over that time. It seems that cron-apt is what I need, but the documentation and syntax is sketchy and unintuitive. Can anyone tell me how to use it to schedule downloads?  It can install the updates at the same time as far as I'm concerned, but that's not such a big issue - I can run those at a later stage.
117949
I have small script that makes screenshot of selected area and then updates it on imgur  function uploadImage {     curl -s -F "image=@$1" -F "key=xxx" https://imgur.com/api/upload.xml | grep -E -o "&lt;original_image&gt;(.)*&lt;/original_image&gt;"  grep -E -o "http://i.imgur.com/[^&lt;]*" }  notify-send "Select screenshot area" FILENAME=$(date +"%d-%m-%Y_%T")".png" scrot -s $FILENAME  uploadImage $FILENAME | xclip -selection c notify-send "Screenshot $FILENAME uploaded. Link copied to clipboard."   i placed it in $home/screenshots/ directory. Everything works fine when i run it from terminal  ./screenshot.sh   but when i try to bind it to key using Default XFCE keybinder with command  bash /path/to/file/screenshot.sh   then it doesn't work. After pressing selected key, I get first norification, and second just moment after. It doesn't make any screenshot, it doesn't even wait for selection. How can i fix it?
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?
77439
Cron doesn't use the path of the user whose crontab it is and, instead, has its own. It can easily be changed by adding PATH=/foo/bar at the beginning of the crontab, and the classic workaround is to always use absolute paths to commands run by cron, but where is cron's default PATH defined?  I created a crontab with the following contents on my Arch system (cronie 1.5.1-1) and also tested on an Ubuntu 16.04.3 LTS box with the same results:  $ crontab -l * * * * * echo "$PATH" &gt; /home/terdon/fff   That printed:  $ cat fff /usr/bin:/bin   But why? The default system-wide path is set in /etc/profile, but that includes other directories:  $ grep PATH= /etc/profile PATH="/usr/local/sbin:/usr/local/bin:/usr/bin"   There is nothing else relevant in /etc/environment or /etc/profile.d, the other files I thought might possibly be read by cron:  $ grep PATH= /etc/profile.d/* /etc/environment /etc/profile.d/jre.sh:export PATH=${PATH}:/usr/lib/jvm/default/bin /etc/profile.d/mozilla-common.sh:export MOZ_PLUGIN_PATH="/usr/lib/mozilla/plugins" /etc/profile.d/perlbin.sh:[ -d /usr/bin/site_perl ] &amp;&amp; PATH=$PATH:/usr/bin/site_perl /etc/profile.d/perlbin.sh:[ -d /usr/lib/perl5/site_perl/bin ] &amp;&amp; PATH=$PATH:/usr/lib/perl5/site_perl/bin /etc/profile.d/perlbin.sh:[ -d /usr/bin/vendor_perl ] &amp;&amp; PATH=$PATH:/usr/bin/vendor_perl /etc/profile.d/perlbin.sh:[ -d /usr/lib/perl5/vendor_perl/bin ] &amp;&amp; PATH=$PATH:/usr/lib/perl5/vendor_perl/bin /etc/profile.d/perlbin.sh:[ -d /usr/bin/core_perl ] &amp;&amp; PATH=$PATH:/usr/bin/core_perl   There is also nothing relevant in any of the files in /etc/skel, unsurprisingly, nor is it being set in any /etc/cron* file:  $ grep PATH /etc/cron* /etc/cron*/* grep: /etc/cron.d: Is a directory grep: /etc/cron.daily: Is a directory grep: /etc/cron.hourly: Is a directory grep: /etc/cron.monthly: Is a directory grep: /etc/cron.weekly: Is a directory /etc/cron.d/0hourly:PATH=/sbin:/bin:/usr/sbin:/usr/bin   So, where is cron's default PATH for user crontabs being set? Is it hardcoded in cron itself? Doesn't it read some sort of configuration file for this?
79804
I need to run shell script contains Xdotool codes in /home/z/Desktop/tempo/run.sh. I've tried many ways of DISPLAY=:0 but always not works.  I've tried each of below codes, and not works:  * * * * * export DISPLAY=:0 cd /home/z/Desktop/tempo; ./run.sh * * * * * export DISPLAY=:0; cd /home/z/Desktop/tempo; ./run.sh * * * * * export DISPLAY=:0 &amp;&amp; cd /home/z/Desktop/tempo; ./run.sh * * * * * DISPLAY=:0 cd /home/z/Desktop/tempo; ./run.sh * * * * * DISPLAY=:0; cd /home/z/Desktop/tempo; ./run.sh * * * * * DISPLAY=:0 &amp;&amp; cd /home/z/Desktop/tempo; ./run.sh   Running directly also not works:  * * * * * export DISPLAY=:0 xdotool mousemove 20 20 * * * * * export DISPLAY=:0; xdotool mousemove 20 20 * * * * * export DISPLAY=:0 &amp;&amp; xdotool mousemove 20 20 * * * * * DISPLAY=:0 xdotool mousemove 20 20 * * * * * DISPLAY=:0; xdotool mousemove 20 20 * * * * * DISPLAY=:0 &amp;&amp; xdotool mousemove 20 20   I always don't see my mouse moving on each line of codes above.  I've also tested Xdotool codes to make invalid website URI request and see the logs. Sadly the logs still blank.