Finger
[ maharG | DeadBeef | Catch22 | Kismet | Display Lines | Search ]
Login: lincoln Name: Lincoln Reid
Directory: /home/lincoln Shell: /bin/bash
Last login Wed Sep 26 11:00 (NZST) on pts/1 from vlan102.guard-dog.acsdata.co.nz
No mail.
No project.

.plan:

When your scripts don't work from cron - Wednesday, 12th September 2018
-----------------------------------------------------------------------

If you've ever had a script that runs fine when you execute it from your regular login shell but won't work from your crontab you may be running into differences between the environment variables that are setup by cron and the environment that a full login shell gets.



If you want to debug this it might be handy to be able to execute a shell with the same environment that cron uses.



You can dump the cron environment to a file by adding a crontab entry to execute env:



So, crontab -e and add this:



* * * * * /usr/bin/env > ~/cronenvironment



Once ~/cronenvironment is populated you can execute a shell using it:



env - `cat ~/cronenvironment` /bin/sh



Then debug away.