braker-scripts icon indicating copy to clipboard operation
braker-scripts copied to clipboard

add_current_shell_and_path_to_crontab

Open dimti opened this issue 9 years ago • 1 comments

Hello

I try to use your script for get default bash env in cron (I found solution from http://stackoverflow.com/questions/2388087/how-to-get-cron-to-call-in-the-correct-paths)

In my crontab, after execute that script, removed some lines (~~Comments~~ and may be wrong records)

Comments moved to begin of the crontab file (edited)

[*] Current SHELL: /bin/bash                                                                                                                           [1/276]
[*] Current PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[*] Adding current SHELL and PATH to crontab 
old crontab:
-------------------------------------------------------------------------------------------------------------------------------
[email protected]
12      0       *       *       *       /usr/local/ispmgr/sbin/update.sh ispmgr >/dev/null 2>&1
23      *       *       *       *       /usr/local/ispmgr/sbin/rotate
44      17      *       *       *       /usr/local/ispmgr/sbin/traffic.pl

* */12 * * *    find /var/www/all/data/mod-tmp/ -cmin +30 -name "sess_*" -delete
*/5 * * * *     /usr/local/ispmgr/sbin/cron.sh sbin/eximquota.check.sh
*/30    *       *       *       *       /usr/local/ispmgr/sbin/dbcache
10 0 * * *      /usr/local/ispmgr/sbin/cron.sh sbin/mgrctl -m ispmgr task.daily
9 2 * * *       /usr/local/ispmgr/sbin/cron.sh sbin/update.sh ispmgr
*/5 * * * *     /usr/local/ispmgr/sbin/cron.sh sbin/ihttpd.check.sh
#*/5 * * * *    /usr/sbin/logrotate /etc/logrotate.d/error-log-custom
0 6 * * *       /usr/sbin/logrotate -f /var/www/all/data/www/zelenoemore.ru/serverconfigs/predelanet/logrotate/zelenoemore.custom.error.log.conf
#*/10 * * * *   truncate --size=0 /var/www/all/data/www/predelanet.ru/cache/face/error.log
#*/10 * * * *    truncate --size=0 /var/www/all/data/www/zelenoemore.ru/cache/face/error.log
*/5 * * * * env - PATH="$PATH" /root/redis-auto-restart.sh
-------------------------------------------------------------------------------------------------------------------------------
[*] New crontab:
-------------------------------------------------------------------------------------------------------------------------------
#*/5 * * * *    /usr/sbin/logrotate /etc/logrotate.d/error-log-custom
#*/10 * * * *   truncate --size=0 /var/www/all/data/www/predelanet.ru/cache/face/error.log
#*/10 * * * *    truncate --size=0 /var/www/all/data/www/zelenoemore.ru/cache/face/error.log
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

[email protected]
12      0       *       *       *       /usr/local/ispmgr/sbin/update.sh ispmgr >/dev/null 2>&1
23      *       *       *       *       /usr/local/ispmgr/sbin/rotate
44      17      *       *       *       /usr/local/ispmgr/sbin/traffic.pl

* */12 * * *    find /var/www/all/data/mod-tmp/ -cmin +30 -name "sess_*" -delete
*/5 * * * *     /usr/local/ispmgr/sbin/cron.sh sbin/eximquota.check.sh
*/30    *       *       *       *       /usr/local/ispmgr/sbin/dbcache
10 0 * * *      /usr/local/ispmgr/sbin/cron.sh sbin/mgrctl -m ispmgr task.daily
9 2 * * *       /usr/local/ispmgr/sbin/cron.sh sbin/update.sh ispmgr
*/5 * * * *     /usr/local/ispmgr/sbin/cron.sh sbin/ihttpd.check.sh
0 6 * * *       /usr/sbin/logrotate -f /var/www/all/data/www/zelenoemore.ru/serverconfigs/predelanet/logrotate/zelenoemore.custom.error.log.conf
-------------------------------------------------------------------------------------------------------------------------------

dimti avatar May 24 '15 07:05 dimti