[ASTPPCOM-261] Crontab entries missing user which makes cron stop working entirely Created: 11/Nov/17  Updated: 01/Apr/21  Resolved: 01/Apr/21

Status: Done
Project: ASTPP Community
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature
Reporter: alexheylin Assignee: Samir Doshi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The crontab entries are added without a user name which causes
cron[510]: Error: bad username; while reading /etc/crontab
cron[510]: (system) ERROR (Syntax error, this crontab file will be ignored)
in syslog. This explains why my cron.hourly hasn't been running.

Inserting a valid user (like root - NOT recommended for production) between the _ _ * and the cd makes it work

# Generate Invoice
0 1 * * * root cd /var/www/html/astpp/cron/ && php cron.php GenerateInvoice
# Low balance notification
0 1 * * * root cd /var/www/html/astpp/cron/ && php cron.php UpdateBalance
# Low balance notification
0 0 * * * root cd /var/www/html/astpp/cron/ && php cron.php LowBalance
# Update currency rate
0 0 * * * root cd /var/www/html/astpp/cron/ && php cron.php CurrencyUpdate
# Email Broadcasting
0 0 * * * root cd /var/www/html/astpp/cron/ && php cron.php BroadcastEmail


 Comments   
Comment by Ketan Kothari (Inactive) [ 28/Dec/17 ]

[~AlexHeylin]

You can setup astpp script in cron like below which is already in installation script. Also that is working fine on centos/debian.

setup_cron()
{
if [ ${DIST} = "DEBIAN" ]; then
CRONPATH='/var/spool/cron/crontabs/astpp'
elif [ ${DIST} = "CENTOS" ]; then
CRONPATH='/var/spool/cron/astpp'
fi
echo "# Generate Invoice
0 1 _ _ * cd /var/www/html/astpp/cron/ && php cron.php GenerateInvoice

  1. Low balance notification
    0 1 _ _ * cd /var/www/html/astpp/cron/ && php cron.php UpdateBalance
  2. Low balance notification
    0 0 _ _ * cd /var/www/html/astpp/cron/ && php cron.php LowBalance
  3. Update currency rate
    0 0 _ _ * cd /var/www/html/astpp/cron/ && php cron.php CurrencyUpdate
  4. Email Broadcasting
    _ _ _ _ * cd /var/www/html/astpp/cron/ && php cron.php BroadcastEmail
    " > $CRONPATH
    chmod 600 $CRONPATH
    crontab $CRONPATH
    }
    Still if you are getting any issue then you need to look in cron configuration on your server.
Generated at Sat Feb 10 07:15:35 CET 2024 using Jira 8.13.3#813003-sha1:22ebedbb75c99b147c66f14e031dd8a2d214753a.