title: Python - "IOError: [Errno 13] Permission denied" when running cron job but not when running from command line
body: <p>I have SSHed from my local machine (a Mac) to a remote machine called “ten-thousand-dollar-bill” as the user “chilge”.</p>
  
  <p>I want to run a Python script in the folder “/afs/athena.mit.edu/c/h/chilge/web_scripts” that generates and saves a .png image to the folder “/afs/athena.mit.edu/c/h/chilge/www/TAF_figures/KORD/1407”. When I run the script from the command line, the image is generated and saved without any issues. When I run the script as cron job, though (the crontab resides in “/afs/athena.mit.edu/c/h/chilge/cron_scripts”), I get the following error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <blockquote>
      <p>File "/afs/athena.mit.edu/user/c/h/chilge/web_scripts/generate_plots.py", line 15, in 
          save_taffig(taf,fig)</p>
      
      <p>File "/afs/athena.mit.edu/user/c/h/chilge/web_scripts/plotting.py", line 928, in save_taffig
          fig.savefig(os.getcwd()+'/'+savename+'.png')</p>
      
      <p>File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1084, in savefig
          self.canvas.print_figure(*args, **kwargs)</p>
      
      <p>File "/usr/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 1923, in print_figure
          **kwargs)</p>
      
      <p>File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 443, in print_png
          filename_or_obj = file(filename_or_obj, 'wb')</p>
      
      <p>IOError: [Errno 13] Permission denied: '/afs/athena.mit.edu/user/c/h/chilge/www/TAF_figures/KORD/1407/140723-1200_AMD_140723-1558.png'</p>
    </blockquote>
  </blockquote>
  
  <p>I believe I’ve correctly changed the permissions of all of the necessary directories, but I’m still getting this error. I am not sure why the script would run fine from the command line, but fail when I try to run the script as a cron job.</p>
  
  <p>(Also, I’m not sure if this will be relevant, but don’t have sudo permissions on the remote machine.)</p>