user1721451
user1721451

Reputation: 247

Linux Raspbian (raspberry Pi) crontab not running sh. Works fine running manually

I've tried every which way to get this working. I originally created a Python script to interact with Twitter. The script runs fine and does what it should do. I added to crontab, but it wouldn't run. I then heard there was some trouble with interaction directly with Python, so wrote a launcher.sh to run the Python script and added this to crontab. Still a no go. The Launcher.sh is executable and running manually works fine. Here's the code:

sudo sh launcher.sh runs fine - this contains a script to run a python script content of launcher:

#!/bin/sh
# launcher.sh
# navigate to home directory

cd /
cd home/pi
sudo python retweet.py
cd / 

In root crontab I have (note this is the root crontab sudo crontab -e):

@reboot 0,15,30,45 * * * * sh /home/pi/launcher.sh >/dev/null 2>&1

This is to run it every 15 minutes. I've also tried /15 * * * *

I've checked the syslog and can see that after a reboot as per this line, that crontab ackknowledges the start on reboot request.

The script however never runs. Here's the syslog:

Jan 22 09:36:12 raspberrypi /USR/SBIN/CRON[2113]: (root) CMD (0,15,30,45 * * * *           sh /home/pi/laucher.sh >/dev/null 2>&1 )

I'm pretty new to the world of Linux, I've read lots and am learning as I go. I hope someone out there can help me.

Upvotes: 1

Views: 3139

Answers (1)

user1721451
user1721451

Reputation: 247

Thanks for all your comments - it was a rookie error on my part. Simply put, you can't have @reboot followed by the time specification. 0 * * * * *. I've removed the @reboot command, and it's all working fine now.

Upvotes: 2

Related Questions