I wrote a python script to autogenerate a background pattern for my computer. I want to use cron to run it every 15 minutes or so. Here's the code:  #!/usr/bin/python import os import numpy as np import svgwrite as svg  WIDTH = 1600 HEIGHT = 900  def circle_layer(dwg, size_range, blur, number):      blur_filter = dwg.defs.add(dwg.filter())     blur_filter.feGaussianBlur(in_='SourceGraphic', stdDeviation=blur)     g_f = dwg.add(dwg.g(filter=blur_filter.get_funciri()))      for c in xrange(0, number):         (x, y) = (np.random.random_integers(0,WIDTH),    np.random.random_integers(0,HEIGHT))         rad = np.random.random_integers(size_range[0], size_range[1])         g_f.add(dwg.circle(center=(str(x),str(y)), r=str(rad),stroke="rgb(100,100,100)", fill="rgb(100,0,0)"))      return dwg     if __name__ == "__main__":      svg_doc = svg.Drawing(filename = "current_wallpaper.svg", size = (str(WIDTH), str(HEIGHT)))      svg_doc.add(svg_doc.rect(insert=(0,0), size=(str(WIDTH), str(HEIGHT)), fill="rgb(0,0,0)"))       svg_doc = circle_layer(svg_doc, (10,50),  20, 100)     svg_doc = circle_layer(svg_doc, (10, 20), 4, 100)      svg_doc.save()      import subprocess      proc = subprocess.Popen(["pgrep gnome-session"], stdout=subprocess.PIPE, shell=True)     (pid, err) = proc.communicate()     pid = pid.rstrip('\t\r\n\0')     print repr(pid)      cmd = "grep -z DBUS_SESSION_BUS_ADDRESS /proc/"+pid+"/environ|cut -d= -f2-"     proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, shell=True)     (out, err) = proc.communicate()     out = out.rstrip('\t\r\n\0')     print repr(out)       cmd = "export DBUS_SESSION_BUS_ADDRESS=$"+out     print repr(cmd)     os.system(cmd)      os.system("/usr/bin/gsettings set org.gnome.desktop.background picture-uri file:///home/jofo/Pictures/Wallpapers/current_wallpaper.svg")     print "I ran!"   Basically, it uses svgwrite to draw some circles and add a gaussian blur. Then, I make a system call to gsettings to update the ubuntu wallpaper.   This works fine when I run it as ./wallpaper.py, but when I schedule it in crontab, the script runs, and the background pattern doesn't change.  Here's what I have in my crontab file doohickey:  MAILTO="" */1 * * * * /home/jofo/Pictures/Wallpapers/./wallpaper.py &gt;&gt; /home/jofo/Pictures/Wallpapers/cron.log   I know the script is running once a minute because it appends "I ran!" to the cron.log file once per minute. Unfortunately, the wallpaper never changes. If anyone knows why this might be, that would be great!
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.
3822
I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically.   Basically I just want to run through the database and make some calculations/updates on an automatic, regular basis, but I can't seem to find any documentation on doing this.  Does anyone know how to set this up?  To clarify:  I know I can set up a cron job to do this, but I'm curious if there is some feature in Django that provides this functionality.   I'd like people to be able to deploy this app themselves without having to do much config (preferably zero).  I've considered triggering these actions "retroactively" by simply checking if a job should have been run since the last time a request was sent to the site, but I'm hoping for something a bit cleaner.
119671
I've basically re-written the terminal output instead of appending a series of edits to this question:  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# tail /var/log/syslog  Dec 21 11:35:01 doge cron[820]: (*system*doge2) RELOAD (/etc/cron.d/doge2) Dec 21 11:35:01 doge cron[820]: Error: bad username; while reading /etc/cron.d/doge2 Dec 21 11:35:01 doge cron[820]: (*system*doge2) ERROR (Syntax error, this crontab file will be ignored) Dec 21 11:38:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge3 Dec 21 11:38:01 doge cron[820]: (*system*doge3) ERROR (Syntax error, this crontab file will be ignored) Dec 21 11:56:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge4 Dec 21 11:56:01 doge cron[820]: (*system*doge4) ERROR (Syntax error, this crontab file will be ignored) Dec 21 11:56:01 doge cron[820]: (*system*doge) RELOAD (/etc/cron.d/doge) Dec 21 11:56:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge Dec 21 11:56:01 doge cron[820]: (*system*doge) ERROR (Syntax error, this crontab file will be ignored) root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat doge * * * * * /home/digger/webxass root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat doge2 * * * * * /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt;  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat doge4 * * * * * /home/digger/webxass root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat /home/digger/webxass  /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt; root@doge:/etc/cron.d#  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt; [2013-12-21 11:57:09] 1 miner threads started, using 'scrypt' algorithm. [2013-12-21 11:57:09] Starting Stratum on stratum+tcp://doge.pool.webxass.de:3333 [2013-12-21 11:57:09] Stratum detected new block [2013-12-21 11:57:11] thread 0: 4104 hashes, 6.24 khash/s [2013-12-21 11:57:43] Stratum detected new block [2013-12-21 11:57:43] thread 0: 211512 hashes, 6.46 khash/s [2013-12-21 11:58:43] thread 0: 387384 hashes, 6.47 khash/s [2013-12-21 11:58:48] Stratum detected new block [2013-12-21 11:58:48] thread 0: 32964 hashes, 6.47 khash/s ^C root@doge:/etc/cron.d#  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat /home/digger/webxass /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt; root@doge:/etc/cron.d#  root@doge:/etc/cron.d# su digger digger@doge:/etc/cron.d$  digger@doge:/etc/cron.d$ /home/digger/webxass  [2013-12-21 11:59:51] 1 miner threads started, using 'scrypt' algorithm. [2013-12-21 11:59:51] Starting Stratum on stratum+tcp://doge.pool.webxass.de:3333 [2013-12-21 11:59:51] Stratum detected new block ^Cdigger@doge:/etc/cron.d$    There's some sort of syntax error, but I don't know what it is.    I really don't understand the "bad username" error, digger is a valid user.  Which username is bad?  The digger username in the system?
11663
I am looking for a way to clean up the mess when my top-level script exits.  Especially if I want to use set -e, I wish the background process would die when the script exits.
61906
I have a bunch of PNG images on a directory. I have an application called pngout that I run to compress these images. This application is called by a script I did. The problem is that this script does one at a time, something like this:  FILES=(./*.png) for f in  "${FILES[@]}" do         echo "Processing $f file..."         # take action on each file. $f store current file name         ./pngout -s0 $f R${f/\.\//} done   Processing just one file at a time, takes a lot of time. After running this app, I see that the CPU is just 10%. So I discovered that I can divide these files in 4 batches, put each batch in a directory and fire 4, from four terminal windows, four processes, so I have four instances of my script, at the same time, processing those images and the job takes 1/4 of the time.  The second problem is that I lost time dividing the images and batches and copying the script to four directories, open 4 terminal windows, bla bla...  How do that with one script, without having to divide anything?  I mean two things: first how do I from a bash script, fire a process to the background ? (just add &amp; to the end?) Second: how do I stop sending tasks to the background after sending the fourth tasks and put the script to wait until the tasks end? I mean, just sending a new task to the background as one tasks end, keeping always 4 tasks in parallel? if I do not do that the loop will fire zillions of tasks to the background and the CPU will clog.
61294
I want to create and elevation hillshade but I found the script for QGIS 2.18. What should I use instead of processing.runandload? Here is my script on QGIS 2.99 python console:  import processing rasterLyr = QgsRasterLayer("C:/Users/Mustafa Uçar/Desktop/Tutorial/qgis_data/dem/dem.asc", "hillshade") rasterLyr.isValid() processing.runandload("gdalogr:hillshade", rasterLyr, 1, False, False,1.0, 1.0, 315.0, 45.0, "C:/Users/Mustafa Uçar/Desktop/Tutorial/qgis_data/dem/hillshade.tif") #to verify the output image processing.runandload()
6876
Can I use below code to set cron job for every 5 hours?   0 */5 * * * script.sh   What time my script.sh will be executed?   0000, 0500, 1000, 1500, 2000, 0100, 0600, 1100, 1600, 2100 and so on...    OR   0000, 0500, 1000, 1500, 2000, 0000, 0500, 1000, 1500, 2000 and so on...   If we can not set cron job for every 5 hours with this traditional method, is there any other way to set such job?
111531
I have written up a script for my model. But there is a bit of a problem with it. As in I have to run the script every time I open the file. I want the script to run automatically when I open the blender File.
106055
I am trying to make a script which selects every .png file in a folder beginning with the letters "LG". I then want the scipt create a shapefile, replacing the "LG" with "SH", and then i want the script to buffer that shapefile and rename the buffer with the first 2 letters being "SB".  I keep getting an error 99999 error message at line 37! ( gp.RasterToPolygon_conversion(INPUT_RASTER, Output_polygon_features, "SIMPLIFY", "VALUE") )  I have posted this on stackoverflow.com but probably here is a better place as scripting for arcmap is probably quite specialised!  Can anyone offer me any advice to why this script doesnt work? I am running ArcMap 9.3.1. and (attempting) to run the script from pyscripter!  # --------------------------------------------------------------------------- # RASTER2POLYGON.py # Created on: Wed Dec 01 2010 12:20:48 PM #   (generated by ArcGIS/ModelBuilder) # Usage: RASTER2POLYGON &lt;INPUT_RASTER&gt; &lt;Output_polygon_features&gt; &lt;Raster_Buffer_shp&gt; # ---------------------------------------------------------------------------  # Import system modules import sys, string, os, arcgisscripting  # Create the Geoprocessor object gp = arcgisscripting.create()  # Load required toolboxes... gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx") gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx")  # Script arguments...  folder = "D:\\J04-0083\\IMAGEFILES" for root, dirs, filenames in os.walk(folder): # returms root, dirs, and files     for filename in filenames:         filename_split = os.path.splitext(filename) # filename and extensionname (extension in [1])         filename_zero = filename_split[0]     try:         first_2_letters = filename_zero[0] + filename_zero[1]     except:         first_2_letters = "XX"      if first_2_letters == "LG":         Output_polygon_features = "D:\\J04-0083\\ShapeFiles.gdb\\" + "SH_" + filename + ".shp"          # Process: Raster to Polygon...          INPUT_RASTER = os.path.join(root + "\\" + filename_zero + ".png")         gp.RasterToPolygon_conversion(INPUT_RASTER, Output_polygon_features, "SIMPLIFY", "VALUE")           Distance__value_or_field_ = "5 Meters"         Raster_Buffer_shp = "SB_" + filename + ".shp"          # Process: Buffer...         gp.Buffer_analysis(Output_polygon_features, Raster_Buffer_shp, Distance__value_or_field_, "FULL", "ROUND", "NONE", "")
51666
I have created a neural network that can identify watermarks and can classify them to which company do they belong. Now I created a script that will identify watermark from a folder and move them to different folders where they belong. But this script is quite slow and consumes too much RAM. What should I do to improve it?  from keras.preprocessing.image import img_to_array from keras.models import load_model import numpy as np import argparse import imutils import pickle import cv2 import os import time  import glob import shutil import csv d = glob.glob("colabData/Krishna/*.jpg") print("Total Number of Images are :" ,len(d))  count = 0 final_data = [] def convertToRGB(img):      return cv2.cvtColor(img, cv2.COLOR_BGR2RGB)  for images in d:     count += 1     test1 = cv2.imread(images)     sublist = []     output = test1.copy()     image = cv2.resize(test1, (96, 96))     image = image.astype("float") / 255.0     image = img_to_array(image)     image = np.expand_dims(image, axis=0)      model = load_model("colabData/pokedex.model")     lb = pickle.loads(open("colabData/lb.pickle", "rb").read())     proba = model.predict(image)     idx = np.argmax(proba)     label = lb.classes_[idx]     if not os.path.exists(label):         os.makedirs(label)     sublist.append(label)     if label=="Commonfloor":         shutil.move(images, "colabData/commonfloorr")         print("WaterMark is Available", images, label)     elif label=="Housing":         shutil.move(images, "colabData/housingg")         print("WaterMark is Available", images, label)     elif label=="Sulekha":         shutil.move(images, "colabData/sulekhaa")         print("WaterMark is Available", images, label)     elif label=="Magicbricks":         shutil.move(images, "colabData/magicbrickss")         print("WaterMark is Available",images, label)     elif label=="Property_Wala":         shutil.move(images, "colabData/propertywalaa")         print("WaterMark is Available", images, label)     elif label=="Non-Watermark":         shutil.move(images, "colabData/nonwatermarkk")         print("WaterMark is Not Available", images, label)     elif label=="FloorPlans":         shutil.move(images, "colabData/floorplann")         print("WaterMark is Not Available", images, label)     elif label=="MasterPlan":         shutil.move(images, "colabData/masterplann")         print("WaterMark is Not Available", images, label)     else:         print("Unable to classify")     print(count)     final_data.append(sublist)  filename = "data.csv" with open("colabData/"+filename,'w') as csvfile:     csvfile = csv.writer(csvfile, delimiter=',')     csvfile.writerow("")     for i in range(0, len( final_data )):         csvfile.writerow( final_data[i]  )
82434
This is the script I use:  find /path/backups/ -type f -mtime -2 -printf '%P\n' | rsync -avz --progress --delete --exclude-from=- -e "ssh -p 512" /path/backups/ me@host:/remote/path/server-backups/   This is from the log:  &gt; Jan 21 15:32:01 servername CRON[14654]: (serveruser) CMD (find /path/backups/ -type f -mtime -2 -printf ')   I've tried using cron.d, crontab -e and cron.daily. Both putting the script directly in the crontab file as well as calling a .sh script file. Any ideas how I would go about solving this?
62982
I have a cron job that runs every minute on an Ubuntu 12.04 box  $sudo crontab -e * * * * * mylogin /pathto/file.sh &gt; /log/filelog   If I run file.sh, the bash script does some stuff and echos out runs:  $ ./file.sh  runs   If I check the log of cron tab it shows that the job is running:  Jul 10 12:41:01 localhost CRON[1811]: (root) CMD (mylogin /pathto/file.sh &gt; /log/filelog) Jul 10 12:41:01 localhost CRON[1810]: (CRON) info (No MTA installed, discarding output) Jul 10 12:42:01 localhost CRON[1813]: (root) CMD (mylogin /pathto/file.sh &gt; /log/filelog)   However, the script is not running. It is not doing it's work and not echoing runs to /log/filelog.  $cat /log/filelog  #shows nothing   What other steps can I take to debug this problem?
46129
I really like the look of the output of   But that script is only used for Input/Output operations.  How can I use it as a replacement for sleep but with visual feedback?  sleep 10
118452
I have a long running BASH script that I am running under CYGWIN on Windows.  I would like to limit the script to run for 30 seconds, and automatically terminate if it exceeds this limit. Ideally, I'd like to be able to do this to any command.  For example:  sh-3.2$ limittime -t 30 'myscript.sh'   or   sh-3.2$ limittime -t 30 'grep func *.c'   Under cygwin the ulimit command doesn't seem to work.   I am open to any ideas.
51391
Is there a way to add lines to a user's cron via script?  I usually do it using crontab -e, but I would like to automate this task with a shell script.
17548
So I wish to create and object and set it's shading to 'smooth' using python. It seems simple enough but after trying every method I could find on the internet none of them worked for me. Here's a short example script where the object needs to have smooth shading:  import bpy from mathutils import Vector  verts = [(0,0,0),(0,5,0),(0.25,5,0),(0.25,0,0),(0,0,5),(0,5,5),(0.25,5,5),(0.25,0,5)] faces = [(0,1,2,3), (4,5,6,7), (0,4,5,1), (1,5,6,2), (2,6,7,3), (3,7,4,0)]  grat1mesh = bpy.data.meshes.new("grat1") grat1obj = bpy.data.objects.new("grat1", grat1mesh) grat1obj.location = (5, -5, 0) bpy.context.scene.objects.link(grat1obj) grat1mesh.from_pydata(verts,[],faces) grat1mesh.update(calc_edges=True)  grat2obj = grat1obj.copy() grat2obj.data = grat1mesh.copy() bpy.context.scene.objects.link(grat2obj) grat2obj.location += Vector((-0.125, 1.25, 1.25)) grat2obj.scale = (2, 0.5, 0.5)  bm = grat1obj.modifiers.new("Chop", 'BOOLEAN') bm.object = grat2obj bm.operation = 'DIFFERENCE' bpy.context.scene.objects.active = grat1obj bpy.ops.object.modifier_apply(modifier=bm.name) bpy.context.scene.objects.unlink(grat2obj)   I found this online and tried to place it at the end of the script:  smoothings = [] smoothings.append(face.use_smooth) me_ob.faces.foreach_set("use_smooth", smoothings)   However this just returned an error on the second line, perhaps as it was from an older website. Obviously using a simple bpy.ops.object.shade_smooth() didn't work and I'm kind of stumped as of what to do here!
6379
I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:  0 * * * * echo hello &gt;&gt; ~/cron-logs/hourly/test`date "+%d"`.log   Unfortunately I get this message when that runs:  /bin/sh: -c: line 0: unexpected EOF while looking for matching ``' /bin/sh: -c: line 1: syntax error: unexpected end of file   I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this?