Hello, I'm working on a project, and VMware has problems with suspending the virtual machine. We are accessing the machine through samba. However, when I suspend the VM, it stops the Samba service.
The solution we hit upon was to run a script that checks, say, once a minute to determine whether the machine was active or suspended. If it's been longer than a minute, we restart the samba service. I have been able to manually execute the script, and it properly restarts the service. When running from cron, however, the service won't restart. I am able to write the file out, so I know it's running the script. Is there something in the way I'm calling with the subprocess.call() function that's not able to work through cron? My concern is that I'm using sudo, and that may be where the problem lies. I've had the process run as both root and as localuser in the crontab, both with and without "sudo"ing the command. None works. I don't know how cron would run a sudo command in this case, anyways... Any hints would be appreciated. ---------- #!/usr/bin/python import os.path import time import subprocess t = str(int(time.time())) f = "gasr.dat" if os.path.exists(f): file = open(f,'r') timestamp = file.readline() file.close() cur_time = int(time.time()) difference_in_mins = (cur_time - int(timestamp))/60 if difference_in_mins > 1: subprocess.call('sudo /etc/init.d/samba restart', shell=True) file = open(f,'w') file.write(t) file.close() -- http://mail.python.org/mailman/listinfo/python-list