Angelojoseph17 Posted September 26, 2011 Share Posted September 26, 2011 Hi, I have a php script that is meant to run daily which queries an oracle database and stores results in a csv file before emailing it to certain users. However when run on crontab or even manually the script is killed by the system. Has anyone got any suggestions on where i would need to look to check for error logs. Emails are sent using the mail php class. Also the data attached in the email is usually around 12mb. Many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/ Share on other sites More sharing options...
sunfighter Posted September 27, 2011 Share Posted September 27, 2011 There is a time out limit for php scripts. This is for the protection of the server. Since it happens when run manually I suspect an infinite loop in your script. Post it here and we'll give it a look see. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273042 Share on other sites More sharing options...
epixeltechnologies Posted September 27, 2011 Share Posted September 27, 2011 Try with out any attachment as some times attachment takes more time then session timing set by us.so the page is killed. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273147 Share on other sites More sharing options...
Angelojoseph17 Posted September 27, 2011 Author Share Posted September 27, 2011 The attachment is a oracle query converted into excel which i suspect is the issue as the file gets as big as 13 mb. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273151 Share on other sites More sharing options...
thehippy Posted September 27, 2011 Share Posted September 27, 2011 PHP has memory limits and sometimes the CLI and webserver configurations may be setup differently, but you'd probably error out the script running it manually, and I'll assume you've already checked PHPs error_log. You could be using too much system memory (imposed through ulimit), if its the system try syslog, usually /var/log/messages or somewhere under /var, if you're sending through a local mailer try /var/log/mail.log or again something similar under /var. If you're connecting to a remote mail server you're going to have to develop or use a more sophisticated mail class to recognize errors from the server as the mail function only returns a boolean. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273171 Share on other sites More sharing options...
Angelojoseph17 Posted September 27, 2011 Author Share Posted September 27, 2011 thanks i will have a look at the logs. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273194 Share on other sites More sharing options...
Angelojoseph17 Posted September 27, 2011 Author Share Posted September 27, 2011 Just had a look at the logs all seem normal or dont tell much apart from the syslog. This is the error message on there at the time where crontab is meant to run this script: Sep 27 09:50:48 IT kernel: [1726073.814062] php invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0 Sep 27 09:50:48 IT kernel: [1726073.814137] php cpuset=/ mems_allowed=0 Sep 27 09:50:48 IT kernel: [1726073.814160] Pid: 979, comm: php Not tainted 2.6.32-30-generic #59-Ubuntu Sep 27 09:50:48 IT kernel: [1726073.814182] Call Trace: Sep 27 09:50:48 IT kernel: [1726073.814291] [<c01ce494>] oom_kill_process+0xa4/0x2b0 Sep 27 09:50:48 IT kernel: [1726073.814304] [<c01ceb09>] ? select_bad_process+0xa9/0xe0 Sep 27 09:50:48 IT kernel: [1726073.814310] [<c01ceb91>] __out_of_memory+0x51/0xa0 Sep 27 09:50:48 IT kernel: [1726073.814316] [<c01cec38>] out_of_memory+0x58/0xb0 Sep 27 09:50:48 IT kernel: [1726073.814322] [<c01d1517>] __alloc_pages_slowpath+0x487/0x4a0 Sep 27 09:50:48 IT kernel: [1726073.814329] [<c01d166a>] __alloc_pages_nodemask+0x13a/0x170 Sep 27 09:50:48 IT kernel: [1726073.814336] [<c01d3c2a>] __do_page_cache_readahead+0xea/0x200 Sep 27 09:50:48 IT kernel: [1726073.814342] [<c01d3d66>] ra_submit+0x26/0x30 Sep 27 09:50:48 IT kernel: [1726073.814348] [<c01ccf0c>] filemap_fault+0x3dc/0x410 Sep 27 09:50:48 IT kernel: [1726073.814373] [<c01e6440>] __do_fault+0x40/0x490 Sep 27 09:50:48 IT kernel: [1726073.814380] [<c01d4a51>] ? lru_cache_add_lru+0x21/0x40 Sep 27 09:50:48 IT kernel: [1726073.814387] [<c01ef024>] ? page_add_new_anon_rmap+0x64/0x70 Sep 27 09:50:48 IT kernel: [1726073.814393] [<c01e80a9>] handle_mm_fault+0x139/0x390 Sep 27 09:50:48 IT kernel: [1726073.814471] [<c05918cd>] do_page_fault+0x10d/0x3a0 Sep 27 09:50:48 IT kernel: [1726073.814496] [<c05917c0>] ? do_page_fault+0x0/0x3a0 Sep 27 09:50:48 IT kernel: [1726073.814502] [<c058f7c3>] error_code+0x73/0x80 Sep 27 09:50:48 IT kernel: [1726073.814513] Mem-Info: I will increase the ulimit of my user account its currently at 1024. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273195 Share on other sites More sharing options...
thehippy Posted September 27, 2011 Share Posted September 27, 2011 You could also work within the means of the memory limitation and use file chunking to read in and send the data. Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273204 Share on other sites More sharing options...
Angelojoseph17 Posted September 27, 2011 Author Share Posted September 27, 2011 This server is on a virtual machine. I increased the memory and the script ran. I will let it run on crontab tommorow and tell you how it goes. Many thanks Angelo Quote Link to comment https://forums.phpfreaks.com/topic/247891-php-script-on-crontab/#findComment-1273206 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.