Welcome to our community

Be a part of something great, join today!

Need linux/python help with writing to csv file in cron

  • Thread starter
  • Admin
  • #1

Greg Bernhardt

Administrator
Staff member
Feb 3, 2012
129
I'm writing a simple script that writes to a csv file. When ran from console it works fine. When ran with cron, it doesn't write. No errors in the log. All files and folders are 777. The cron is active and running. What am I missing?
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,679
What do:
Code:
$ dmesg
$ cat /var/log/syslog
say?
If there was an error, it should show up in one of those.

How do you know that the script is actually running?

I recommend to start the script with something like
Code:
#!/bin/bash
logger "Running simple script that writes to csv file"
so that there will always be an entry in the syslog. Note that standard output does not go anywhere.
If after that, there is still no entry in the log (after waiting for the script to trigger), that implies that the script did not actually run.
 
  • Thread starter
  • Admin
  • #3

Greg Bernhardt

Administrator
Staff member
Feb 3, 2012
129
oh derp, I had a relative path to the file :D
 

Ackbach

Indicium Physicus
Staff member
Jan 26, 2012
4,183
I have found cron to be extremely picky about security settings, and not very helpful at steering you to set them correctly.
 

Jameson

Administrator
Staff member
Jan 26, 2012
4,029
Seems like a good place to ask this, how many of you use Python at work or for personal projects? 3 years ago I had never once touched it now it’s my go to language. Still not my best but the dominance it has in data science plus the huge variety of tasks it can do are very appealing.
 
  • Thread starter
  • Admin
  • #6

Greg Bernhardt

Administrator
Staff member
Feb 3, 2012
129
Seems like a good place to ask this, how many of you use Python at work or for personal projects? 3 years ago I had never once touched it now it’s my go to language. Still not my best but the dominance it has in data science plus the huge variety of tasks it can do are very appealing.
Agreed, I'm just a few months in and I love it. It's so clean. Looking at nested indents can take getting used to. There are also so many libraries, great community.
 

Jameson

Administrator
Staff member
Jan 26, 2012
4,029
The nested part was weird for me at first but with a good editor like Sublime the coloring and formatting help make it very obvious what code goes to what chunk.
 

Ackbach

Indicium Physicus
Staff member
Jan 26, 2012
4,183
I'm still slightly better at LabVIEW (and was therefore extremely excited when NI put out the Community Edition), but I like many things about Python. As text-based languages go, it's my favorite, because it appears optimized for developer time.

I do all my projects using various databases (either relational with SQL, or now I'm starting to use Neo4J with Cypher) and Python. That's it.