Reputation: 1471
In my /etc/crontab file I write:
* * * * * PLACK_ENV=development -I /home/adrian/app/lib/ /home/adrian/app/script/db/log_to_db.pl
To make a cron job run every minute. The job is running the log_to_db.pl perl script, which inserts data to my database.
When I run in my terminal PLACK_ENV=development -I /home/adrian/app/lib/ /home/adrian/app/script/db/log_to_db.pl It's OK! The script runs.
But the cron job isn't working! What can be wrong?
PD: My script starts like
#!/usr/bin perl
....
My cron log prints:
Jul 8 20:29:01 dev0001 crond[1829]: (*system*) RELOAD (/etc/crontab)
Jul 8 20:29:01 dev0001 crond[1829]: (CRON) bad username (/etc/crontab)
Jul 8 20:30:01 dev0001 crond[1829]: (*system*) RELOAD (/etc/crontab)
Jul 8 20:30:01 dev0001 crond[1829]: (CRON) bad username (/etc/crontab)
Jul 8 20:30:01 dev0001 CROND[13504]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Upvotes: 1
Views: 3959
Reputation: 20232
You need a username when putting it in the system crontab
* * * * * adrian PLACK_ENV=development -I /home/adrian/app/lib/ /home/adrian/app/script/db/log_to_db.pl
But as @jithin said, putting this in your user crontab (crontab -e) might make more sense.
Upvotes: 4