Cronjob does not work

6 4252

I try to start a php script with an cronjob.

  1. EDITOR=nano crontab -u www-data -e
Copy the Code
i put this code in:

  1. 0 * * * * php /var/www/cron/store_data_hourly.php >/dev/null 2>&1
Copy the Code
but nothings happens. If I take a (free) cronjob from outside it is working..
  1. nano /var/log/syslog
Copy the Code
shows every minute:
  1. Jan  7 21:34:01 bananapi /USR/SBIN/CRON[3222]: (root) CMD (/var/www/cron/fakedata.php >/dev/null 2>&1)
Copy the Code
But nothing happens..

I've read somewhere there is a problem beeing root and making this cronjob, so you have to change to a non-root-user!?

it was described like:
  1. su -m nobody -c "/usr/bin/php /home/apache/html/rss/update.php --feeds --quiet"
Copy the Code
but I don't really understand that, it's to high for me.

Can somebody help me please!?

What happens when you execute this command on the command line:
  1. php /var/www/cron/store_data_hourly.php
Copy the Code
You know the crontab syntax?
The format is:
# m h dom mon dow user  command
So your crontab would be executed hourly at minute 0.

Do not play with su(do) at all. You are just trying to execute a php script, this will work as far as the user has access to the files.

It also doesn't hurt to put php in you cronjob with it's full path...

Pull the part of your crontab entry that says >/dev/null 2>&1 and you may see the answer sent to the mail account of the cron job's userid.

I know nothing as yet of the banana pi or bananian, but I've been debugging cron scripts I inherited on Solaris and AIX since October and the one piece of wisdom I can offer any unix programmer/admin as a result of my experiences would be never redirect stuff to the bit bucket until you have several successful runs worth of stdout spam in the mailbox. Personally, I hate it when people redirect stderr to the bit bucket instead of figuring a way to deal with the meaningless and/or expected errors as it masks those times when stuff goes strange, but there are times when that is the most expedient way of getting the job done.


cronjobs are usually run by /bin/sh

Not /bin/bash or /bin/zsh or /usr/bin/php

It maight help to use a she-bang in your php script, like #!/usr/bin/php in it's first line


I am doing a project in PHP. I have downloaded many materials on this from top 5 essay writing services. I am glad to get this site.

I am very much interested in programming and I never miss the chance of studying new languages. While learning Cronjob from the tutorial I was stuck with certain doubts and it was cleared with the help of this post. garage door installation Manhattan Beach

You have to log in before you can reply Login | Sign Up

Points Rules