zwbetz-gh / zwbetz

My personal site
https://zwbetz.com/
MIT License
16 stars 5 forks source link

Cannot schedule the bash script using crontab linux scheduler #4

Closed sankara1 closed 3 years ago

sankara1 commented 3 years ago

Cannot schedule the bash script using crontab linux scheduler.

the below line in the code : source .env

creates an issue when scheduling the script in crontab . it works fine when run normally . please help.

zwbetz-gh commented 3 years ago

What article of my site is this issue in reference to?

In the meantime, give the exact error message you're seeing.

Okay, I'll try to help while flying blind. Keep in mind that source is a bash-specific keyword. If you're in sh then you will have to use . instead like

. .env
sankara1 commented 3 years ago

Connect to an oracle database and run a query from a bash script

Thanks again for helping in this ...the article is very useful and helps a lot

Regards Sankara

On Wed, Jul 21, 2021, 9:07 PM zwbetz-gh @.***> wrote:

What article of my site is this issue in reference to?

In the meantime, give the exact error message you're seeing.

Okay, I'll try to help while flying blind. Keep in mind that source is a bash-specific keyword. If you're in sh then you will have to use . instead like

. .env

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884287934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZD5CJAQHDBR6T5L3XEPF3TY3SVHANCNFSM5AYGR64Q .

zwbetz-gh commented 3 years ago

This one, got it. https://zwbetz.com/connect-to-an-oracle-database-and-run-a-query-from-a-bash-script/

Happy to hear it was useful.

If you want more help, you'll have to provide a detailed error message.

sankara1 commented 3 years ago

We don't get an error message but

source .env Or . .env

Both aren't working via crontab

On Wed, Jul 21, 2021, 9:15 PM zwbetz-gh @.***> wrote:

This one, got it.

https://zwbetz.com/connect-to-an-oracle-database-and-run-a-query-from-a-bash-script/

Happy to hear it was useful.

If you want more help, you'll have to provide a detailed error message.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884293246, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZD5CPPT7B5ACR2D2I5X5DTY3TRZANCNFSM5AYGR64Q .

zwbetz-gh commented 3 years ago

Is the .env file in the same directory as the script?

You could also adjust the source command and give the absolute path to the .env file.

On Wed, Jul 21, 2021 at 10:51 AM sankara1 @.***> wrote:

We don't get an error message but

source .env Or . .env

Both aren't working via crontab

On Wed, Jul 21, 2021, 9:15 PM zwbetz-gh @.***> wrote:

This one, got it.

https://zwbetz.com/connect-to-an-oracle-database-and-run-a-query-from-a-bash-script/

Happy to hear it was useful.

If you want more help, you'll have to provide a detailed error message.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884293246, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIZD5CPPT7B5ACR2D2I5X5DTY3TRZANCNFSM5AYGR64Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884297302, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI4WX7HTMG5SRICJGFBPFXTTY3UHBANCNFSM5AYGR64Q .

sankara1 commented 3 years ago

Yes ...it's in the same path ... I tried with absolute path for env but again it didn't work via crontab but working independently..

On Wed, Jul 21, 2021, 9:24 PM zwbetz-gh @.***> wrote:

Is the .env file in the same directory as the script?

You could also adjust the source command and give the absolute path to the .env file.

On Wed, Jul 21, 2021 at 10:51 AM sankara1 @.***> wrote:

We don't get an error message but

source .env Or . .env

Both aren't working via crontab

On Wed, Jul 21, 2021, 9:15 PM zwbetz-gh @.***> wrote:

This one, got it.

https://zwbetz.com/connect-to-an-oracle-database-and-run-a-query-from-a-bash-script/

Happy to hear it was useful.

If you want more help, you'll have to provide a detailed error message.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884293246, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIZD5CPPT7B5ACR2D2I5X5DTY3TRZANCNFSM5AYGR64Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884297302, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AI4WX7HTMG5SRICJGFBPFXTTY3UHBANCNFSM5AYGR64Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884299991, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZD5CK7A3YHUMWHWUH2LP3TY3UVFANCNFSM5AYGR64Q .

zwbetz-gh commented 3 years ago

Hmm, not sure then. This one is hard to troubleshoot remotely.

On Wed, Jul 21, 2021 at 11:06 AM sankara1 @.***> wrote:

Yes ...it's in the same path ... I tried with absolute path for env but again it didn't work via crontab but working independently..

On Wed, Jul 21, 2021, 9:24 PM zwbetz-gh @.***> wrote:

Is the .env file in the same directory as the script?

You could also adjust the source command and give the absolute path to the .env file.

On Wed, Jul 21, 2021 at 10:51 AM sankara1 @.***> wrote:

We don't get an error message but

source .env Or . .env

Both aren't working via crontab

On Wed, Jul 21, 2021, 9:15 PM zwbetz-gh @.***> wrote:

This one, got it.

https://zwbetz.com/connect-to-an-oracle-database-and-run-a-query-from-a-bash-script/

Happy to hear it was useful.

If you want more help, you'll have to provide a detailed error message.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884293246 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AIZD5CPPT7B5ACR2D2I5X5DTY3TRZANCNFSM5AYGR64Q

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884297302, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AI4WX7HTMG5SRICJGFBPFXTTY3UHBANCNFSM5AYGR64Q

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884299991, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIZD5CK7A3YHUMWHWUH2LP3TY3UVFANCNFSM5AYGR64Q

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884308761, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI4WX7AGHPK5DPVSJ3O3N4TTY3WBZANCNFSM5AYGR64Q .

zwbetz-gh commented 3 years ago

If you're able to debug this more, or even if you come to a solution, feel free to update this issue. For now, closing it.

sankara1 commented 3 years ago

Hi Zwbetz-Gh/Zwbetz

Thanks again for your article and for all your support .

I was luckily able to debug and resolve the issue. The errors after scheduling with crontab were sqlplus not found Oracle-home not found Path for SQL file missing

I added export for Oracle home in shell script , add oracle installation path directly in path under crontab , added full path for the SQL.

This fixed the issue ...I also added !#bin/sh +x so the script supports debug

On Thu, Jul 22, 2021, 12:59 AM zwbetz-gh @.***> wrote:

If you're able to debug this more, or even if you come to a solution, feel free to update this issue. For now, closing it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884440408, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZD5CKI7NUTY6SJTUEDFOTTY4NZZANCNFSM5AYGR64Q .

zwbetz-gh commented 3 years ago

Glad to hear it!

On Thu, Jul 22, 2021 at 2:06 AM sankara1 @.***> wrote:

Hi Zwbetz-Gh/Zwbetz

Thanks again for your article and for all your support .

I was luckily able to debug and resolve the issue. The errors after scheduling with crontab were sqlplus not found Oracle-home not found Path for SQL file missing

I added export for Oracle home in shell script , add oracle installation path directly in path under crontab , added full path for the SQL.

This fixed the issue ...I also added !#bin/sh +x so the script supports debug

On Thu, Jul 22, 2021, 12:59 AM zwbetz-gh @.***> wrote:

If you're able to debug this more, or even if you come to a solution, feel free to update this issue. For now, closing it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884440408, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AIZD5CKI7NUTY6SJTUEDFOTTY4NZZANCNFSM5AYGR64Q

.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/zwbetz-gh/zwbetz/issues/4#issuecomment-884698851, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI4WX7HL5NWAITHHHQDPALTTY67NVANCNFSM5AYGR64Q .