Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron Job uses old non-existent php file

Tags:

php

cron

ubuntu

yii

I'm working with Yii and have to implement a script for cron. I've got a script file, which just calls Yii and starts my php-script file.

Until this point everything is fine. If I'm updating the php-script, Cron just continues executing the old one.

Restart of cron-service, reboot of the server etc didn't help. I also uninstalled cron and installed it again, but nothing changed. He still executes the old version of this php-script.

Anyone an idea what's wrong or what I could do to solve this? I'm using Ubuntu 12.04.

EDIT:

The cronjob script is running:

#!/bin/bash
cd ../www/protected/ ./yiic Cron ProcessPayments

The php-script

class CronCommand extends CConsoleCommand {
public function actionProcessPayments() {
...
}}

This works, but any change I make on this script is ignored by Cron. And now I'm on this point: he executes both. My old version and the new version. I've never been this confused by something.

like image 390
user1151040 Avatar asked Aug 05 '13 14:08

user1151040


People also ask

Where do Cronjobs run from?

Cron jobs run in their owner's home directory When cron jobs are invoked they are run as the user who owns them. This may be different than the user who schedules them.

Do Cronjobs run automatically?

The cron reads the crontab (cron tables) for running predefined scripts. By using a specific syntax, you can configure a cron job to schedule scripts or other commands to run automatically.

Are Cronjobs run as root?

Like any other user, root has a user crontab. Essentially the same as any other user crontab, you are editing the root crontab when you run sudo crontab -e . Jobs scheduled in the root user crontab will be executed as root with all of its privileges.

Why crontab is not working?

Why is crontab not working in your system? Crontab might fail for a variety of reasons: The first reason is that your cron daemon might not be working for any reason, resulting in your crontab failing. There also exists a possibility that your system's environment variables are not settled correctly.


1 Answers

Assuming you have sudo on the machine it's located on...

First check to see if it's located in the usual cron directories /etc/cron.*

sudo find /etc/cron* -mount -iname yiic

If nothing shows up there then search the entire filesystem because otherwise you'll start having to search a lot of other places manually and it takes more time than running a find

sudo find / -mount -iname yiic 

In both find commands if the filename is or has ever been anything other than yiic do yiic* so that it searchs for anything that starts with yiic

Once you have found the copies, if there are any others, remove every single one except the newest one, or even that one and then reinstall the script on the machine from version control.


Edit:

Probably more than you really care about, but the find command breaks down like this:

sudo - elevated priviledges so you can search everywhere as opposed to where you're user can read

find - command to look for thigs

/ - the starting point for the search, can be anywhere

-mount - this tells find not to search other filesystems

-iname - case insensitive name to search for

yiic - the search term

like image 171
Logan Avatar answered Oct 13 '22 00:10

Logan