Cron job errors

Ask your questions regarding TimeTrex installation here.
Post Reply
fvteamsports
Posts: 16
Joined: Mon Jan 23, 2017 10:32 am

Cron job errors

Post by fvteamsports »

I can not get the crontab to work. This is what I have in crontab -e but it will not perform a maint job.

* * * * * su www-data -c "/usr/bin/php /usr/share/timetrex/html/maint/cron.p$

I tried changing users in the above string and also "chown" the directories to every combination I can think of.

I can manually get the jobs to run with 15 of 17 jobs performed and get that red banner off timetrex by executing this:
sudo php /usr/share/timetrex/html/maint/cron.php

Any other command other than sudo creates an authorization failed.

Any ideas?

Timetrex version - 11.5.0
Ubuntu 18.04
php - 7.2
Postgres database
installed using deb package AFTER restoring the database from a windows machine, so it loaded as an upgrade.

mikeb
Posts: 609
Joined: Thu Jul 27, 2006 11:58 am

Re: Cron job errors

Post by mikeb »

The command you pasted here is cut-off at the end (notice the $), can you please paste the full and complete command that you are using?

If that is the full command, then that is likely your problem as its cut-off and missing the last part.
TimeTrex Community Edition is developed and supported by volunteers.
Help motivate us to continue by showing your appreciation!

fvteamsports
Posts: 16
Joined: Mon Jan 23, 2017 10:32 am

Re: Cron job errors

Post by fvteamsports »

Sorry about that, the cut and paste missed the end and I didn't catch it.

This is the full string in the crontab:

* * * * * su www-data -c "/usr/bin/php /usr/share/timetrex/html/maint/cron.php"> /dev/null$

( I have also tried editing that string in multiple ways with no luck, I even set times for it)

The only success I have had is running this manually:

sudo php /usr/share/timetrex/html/maint/cron.php


I'm assuming there is some type of permission issue or peer to peer conflict?

fvteamsports
Posts: 16
Joined: Mon Jan 23, 2017 10:32 am

Re: Cron job errors

Post by fvteamsports »

Sorry screwed that one up also, here it is:

* * * * * su www-data -c "/usr/share/timetrex/html/maint/cron.php"> /dev/null$

mikeb
Posts: 609
Joined: Thu Jul 27, 2006 11:58 am

Re: Cron job errors

Post by mikeb »

There is still a "$" at the end, if that actually is in your crontab, then the command would fail as it shouldn't be there.
TimeTrex Community Edition is developed and supported by volunteers.
Help motivate us to continue by showing your appreciation!

fvteamsports
Posts: 16
Joined: Mon Jan 23, 2017 10:32 am

Re: Cron job errors

Post by fvteamsports »

Took the $ off and it still doesn't work.
Can you post an example to a string that is known to work?

fvteamsports
Posts: 16
Joined: Mon Jan 23, 2017 10:32 am

Re: Cron job errors

Post by fvteamsports »

Here is some more info. I can manually run the jobs but I get this output below.

user@timetrex:~$ sudo php /usr/share/timetrex/html/maint/cron.php
ERROR: Running as 'root' forbidden! To avoid permission conflicts, must run as the web-server user instead.
Example: su www-data -c "/usr/bin/php /usr/share/timetrex/html/maint/cron.php"
NOTE: Jobs are scheduled to run at specific times each day, therefore it is normal for only some jobs to be executed each time this file is run.
Jobs Executed: 17 of 17


Now I'll try what they suggested:

user@timetrex:~$ su www-data -c "/usr/bin/php /usr/share/timetrex/html/maint/cron.php"
Password:
su: Authentication failure
user@timetrex:~$

fvteamsports
Posts: 16
Joined: Mon Jan 23, 2017 10:32 am

Re: Cron job errors

Post by fvteamsports »

Below are some more attempts:

NO LUCK:
user@timetrex:~$ su www-data -c "/usr/share/timetrex/html/maint/cron.php"
Password:
su: Authentication failure

NO LUCK:
user@timetrex:~$ su root -c "/usr/share/timetrex/html/maint/cron.php"
Password:
/usr/share/timetrex/html/maint/cron.php: line 1: ?php: No such file or directory
/usr/share/timetrex/html/maint/cron.php: line 2: /bin: Is a directory
/usr/share/timetrex/html/maint/cron.php: line 3: Desktop: command not found
/usr/share/timetrex/html/maint/cron.php: line 4: syntax error near unexpected token `('
/usr/share/timetrex/html/maint/cron.php: line 4: ` * TimeTrex Software Inc. Copyright (C) 2003 - 2018 TimeTrex Software Inc.'

NO LUCK:
user@timetrex:~$ su user -c "/usr/share/timetrex/html/maint/cron.php"
Password:
bash: /usr/share/timetrex/html/maint/cron.php: Permission denied


BUT THIS WORKS, sort of:

user@timetrex:~$ sudo php /usr/share/timetrex/html/maint/cron.php
ERROR: Running as 'root' forbidden! To avoid permission conflicts, must run as the web-server user instead.
Example: su www-data -c "/usr/bin/php /usr/share/timetrex/html/maint/cron.php"
NOTE: Jobs are scheduled to run at specific times each day, therefore it is normal for only some jobs to be executed each time this file is run.
Jobs Executed: 17 of 17

Is there anyone out there running timetrex on ubuntu 18 with working maint jobs running?

What permission should cron.php be set to?

mikeb
Posts: 609
Joined: Thu Jul 27, 2006 11:58 am

Re: Cron job errors

Post by mikeb »

If you remove all lines from your crontab regarding TimeTrex, then in the TimeTrex directory run:

Code: Select all

./install_cron.sh www-data
That should automatically add the proper cron command for you.
TimeTrex Community Edition is developed and supported by volunteers.
Help motivate us to continue by showing your appreciation!

fvteamsports
Posts: 16
Joined: Mon Jan 23, 2017 10:32 am

Re: Cron job errors

Post by fvteamsports »

That is what I needed! Seems to be working now.
Thank you.

Post Reply