Cron/maintenance jobs problem

General support regarding TimeTrex, such as
configuring policies/taxes or processing payroll.
Locked
jgolightly
Posts: 24
Joined: Mon Nov 16, 2009 8:43 am

Cron/maintenance jobs problem

Post by jgolightly »

As with my previous installation of Timetrex, I'm getting the maintenance jobs have not run in 48 hours. I'm running Timetrex on Ubuntu 8.04 Server LTS. Timetrex is my first experience with crontab, so I'm kind of learning as I go here. Here's the line for crontab as provided by the installation:

# m h dom mon dow user command
* * * * * su www-data -c "php /var/www/timetrex/classes/modules/core/../../../maint/cron.php" > /dev/null 2>&1

The comments in /etc/crontab mention that "These files also have username fields, that none of the other crontabs do." It appears that maybe the crontab entry provided by the installation won't work in this particular crontab due to the way this particular crontab is constructed (noted in the commented line above). Will this work as a modified crontab entry for this particular format:

# m h dom mon dow user command
* * * * * www-data php /var/www/timetrex/maint/cron.php > /dev/null 2>&1


Thanks a bunch.


Jim
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Cron/maintenance jobs problem

Post by shaunw »

Both commands should work, we recommend the first one being entered into the "root" user crontab.

The issue is unlikely the crontab line itself, but something else. How did you install TimeTrex, from the .ZIP file?

Have you tried running the command (without the > /dev/null at the end) manually from the command line to see if you get any error messages?
jgolightly
Posts: 24
Joined: Mon Nov 16, 2009 8:43 am

Re: Cron/maintenance jobs problem

Post by jgolightly »

Running the command from the CLI throws a couple of errors about MagicQuotes and PHP MemoryLimit, but probably because I haven't set the proper variables in /etc/php5/cli/php.ini (do I need to do that?). The first time I ran it from the command line this morning, it ran 4 maintenance jobs, created /var/www/timetrex/log/timetrex_cron_last_executed.log and updated it, and finished without any other errors. I have since been watching timetrex_cron_last_executed.log and it is only updating when cron.php is run manually.

I installed Timetrex from the .ZIP standalone installer. I added the recommended line during the installation to /etc/crontab by manually editing the file.

Again, thanks for your quick help.
jgolightly
Posts: 24
Joined: Mon Nov 16, 2009 8:43 am

Re: Cron/maintenance jobs problem

Post by jgolightly »

I have created a root user crontab and entered the above file. I'll watch timetrex_cron_last_executed.log to see if it's updating.

Jim

EDIT: Just to be sure, I should be watching for this file to update once a minute, correct?
jgolightly
Posts: 24
Joined: Mon Nov 16, 2009 8:43 am

Re: Cron/maintenance jobs problem

Post by jgolightly »

Sigh. I love Linux, but I loathe Linux permissions sometimes. /var/www/timetrex/log/timetrex_cron_last_executed.log was created by root, and so www-data is running the cronjob, but cron.php can't update the timetrex_cron_last_executed.log due to bad permissions. I chown'd the file to www-data:www-data and it's updating now just as it should.

All fixed. Thanks for the pointer on installing the cron line in the root user crontab instead of /etc/crontab.


Jim
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Cron/maintenance jobs problem

Post by shaunw »

Yes, permissions are what bites people the most in crontab configuration with TimeTrex.

I recommend deleting all the files/dirs from your TimeTrex cache directory just in case some of them are owned by root as well.
jgolightly
Posts: 24
Joined: Mon Nov 16, 2009 8:43 am

Re: Cron/maintenance jobs problem

Post by jgolightly »

Thanks again, Shaun. As always, I appreciate such fast support.
allanregistos
Posts: 41
Joined: Wed Oct 21, 2009 11:56 pm
Location: Philippines
Contact:

Re: Cron/maintenance jobs problem

Post by allanregistos »

Hi shaunw,

I noticed that in previous versions of TimeTrex (2.x), there is a window in the installer that says I need to setup the cron job:
* * * * * su www-data -c "php /var/www/timetrex/classes/modules/core/../../../maint/cron.php" > /dev/null 2>&1
But when I install the version 3.0.4 and up to 3.0.5 currently, the cron job setup window was gone.
My question is, is the manual setup of cron job was still required? Or it is not?

Thinking that the manual cron job is no longer required by the installer, I deleted the crontab entry, believing that TimeTrex in itself will do the automatic cron job, and added to the fact that I am not getting a warning in TimeTrex when I logged in, unlike in the previous version where we can see a red warning to setup the cron job.

Thanks...
Allan
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Cron/maintenance jobs problem

Post by shaunw »

Yes, the cron jobs are still required, and that setup screen in the installer is still there, but it doesn't appear during upgrades, only initial installs (if you are doing a manual install from the .ZIP file), if you use the automated installer it sets up the cronjob for you.
allanregistos
Posts: 41
Joined: Wed Oct 21, 2009 11:56 pm
Location: Philippines
Contact:

Re: Cron/maintenance jobs problem

Post by allanregistos »

shaunw wrote:Yes, the cron jobs are still required, and that setup screen in the installer is still there, but it doesn't appear during upgrades, only initial installs (if you are doing a manual install from the .ZIP file), if you use the automated installer it sets up the cronjob for you.
Oh I can see, that is why, today, I see the red warning. :), I need to recreate the cronjob. And yes, I regularly use the manual installer.

Thanks for the usual support.
Allan
Locked