基於perl的cron作業不會在長時間不活動后寫入已掛載的cifs / windows共享

[英]perl based cron job won't write to mounted cifs/windows share ONLY after long inactivity


I'm not sure how to title that more succinctly and still have it be meaningful.

我不確定如何更簡潔地標題,仍然有意義。

(Note that this works fine when run mid-day, via cron or manually, so I "know" the script itself is sound.)

(注意,這在中午運行,通過cron或手動運行時效果很好,所以我“知道”腳本本身就是聲音。)

I have a cron job (ubuntu 13.04.)
It runs as my user (not root.)

我有一個cron作業(ubuntu 13.04。)它作為我的用戶運行(不是root。)

The job itself runs at 6:00 in the morning. It's the first 'business level' job that runs all day.

這項工作本身早上6點開始。這是第一個全天運行的“業務水平”工作。

1 6 * * 1-5 /home/me/bin/run_perl_job

run_perl_job is just:

run_perl_job只是:

#!/bin/bash
cd /home/me/bin
./script.pl

The script copies a file to "/mnt/shared_drive/outputfile.xls"

該腳本將文件復制到“/mnt/shared_drive/outputfile.xls”

The mount point is defined in fstab as:

掛載點在fstab中定義為:

//fileserver/share /mnt/shared_drive cifs user=domain/me%password,iocharset=utf8,gid=1000,uid=1000,sec=ntlm,file_mode=0777,dir_mode=0777 0 0

Now. Given that:

現在。鑒於:

  • When I run the script in a normal shell, it works fine.
  • 當我在普通shell中運行腳本時,它工作正常。

  • When I look at the mount point first thing in the morning (via a normal terminal) it shows up (and is writeable) without event.
  • 當我第一眼看到掛載點(通過正常的終端)時,它會顯示(並且可寫)而沒有事件。

  • When I copy the crontab line and set it to run in a couple minutes, to see the symptom, it works fine (creates the file quite happily.)
  • 當我復制crontab行並將其設置為在幾分鍾內運行時,為了查看症狀,它可以正常工作(非常愉快地創建文件。)

The ONLY time this fails is if it's running in its normal time slot (6:01). The rest of the script functions ( the file itself has to be pulled down via sftp, etc.) So I know it's not dying.

這次失敗的唯一時間是它是否在正常時段(6:01)運行。其余的腳本函數(文件本身必須通過sftp等拉下來)所以我知道它不會死。

It's driving me batty because the test cycle is 24 hours.

這讓我感到沮喪,因為測試周期為24小時。

I just added the following couple lines to the beginning of the 'run_perl_job' script, hoping it exposes something tomorrow:

我剛剛將以下幾行添加到'run_perl_job'腳本的開頭,希望它明天暴露一些東西:

cd /mnt/shared_drive
ls -lrt >>home/me/bin/process.log

But I'm stumped. "It's almost as though" the mount point had gotten stale overnight and is waiting for some kind of access attempt before remounting. I'd run "mount -a" at the top of the 'run_perl_job' script if I could reasonably do it. But given that it's got to be sudo'ed, that doesn't seem reasonable to me.

但我很難過。 “這幾乎就好像”掛載點在一夜之間變得陳舊,並且在重新安裝之前正在等待某種訪問嘗試。如果我可以合理地執行它,我會在'run_perl_job'腳本的頂部運行“mount -a”。但鑒於它必須被sudo'ed,這對我來說似乎不合理。

Thoughts? I'm running out of ideas and this test cycle is awful.

思考?我的想法已經用完了,這個測試周期很糟糕。

1 个解决方案

#1


0  

how about putting a

如何放一個

   umount -f -v /mnt/shared_drive
   mount -v -a

into a root cron job just before your script runs. That way you don't need to sudo in your script and have the password in plain sight. -v might give you a hint on what is happening to make it stale

在腳本運行之前進入根cron作業。這樣你就不需要在你的腳本中使用sudo並且密碼很明顯。 -v可能會給你一些提示,讓它變得陳舊


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/07/16/725d0ba807e66d154e9965d3c8a1627c.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com