Thank you for the great work.
I've been able to successfully run a script.
I tried to create a cronjob but it wouldn't work.
After some digging and fumbling around it seems I can only run the script with sudo.
If I try to run the script with sudo I get:
Traceback (most recent call last):
File "InstaPy/followmff.py", line 5, in <module>
session = InstaPy(username='<myuser>', password='<mypass>')
File "/home/<user>/InstaPy/instapy/instapy.py", line 53, in __init__
self.logFile = open('./logs/logFile.txt', 'a')
IOError: [Errno 2] No such file or directory: './logs/logFile.txt'
I have the right permissions set for the InstaPy directory as well as chrome.
(I tried to create a root cronjob but it wouldn't work either. It's not the solution I'm after anyhow)
Would be great if someone has some input.
Cheers
Post your directory structure. Do you have the logs folder and the logsFile.txt inside the logs folder?
My dir structure is the default /home/
It was my fault. The error I was getting as per my previous post was due to the fact that I wasn't inside the InstaPy directory when I was trying to run the script.
However if I try to execute the script while inside the dir, I get:
<user>:~/InstaPy$ sudo python followmff.py
Works perfectly
<user>:~/InstaPy$ python followmff.py
Outputs:
Traceback (most recent call last):
File "followmff.py", line 5, in <module>
session = InstaPy(username='<user>', password='<pass>?')
File "/home/<user>/InstaPy/instapy/instapy.py", line 53, in __init__
self.logFile = open('./logs/logFile.txt', 'a')
IOError: [Errno 13] Permission denied: './logs/logFile.txt'
If I add a cronjob to root by entering
sudo crontab -e
And then check the /var/log/syslog, I can see that the command was executed. However, if I check /InstaPy/logs/logFile.txt, the script did not run.
If I add a cronjob without sudo, by entering
crontab -e
The same permission error I mentioned above is logged, and the script doesn't run.
So I am not sure which files should I change the ownership for (or if that is the way to go).
Post your file permissions for logFile.txt (ls -l logFile.txt) just to check.
I use a virtualenv to run the script. The way I do my cron is: cd to InstaPy directory && activate virtualenv && run quickstart.py && deactivate virtualenv.
Some things that stumped me when setting up the cron:
-rwxr-xr-x 1 root root 2484 Sep 19 18:33 logs/logFile.txt
This is the logFile.txt permissions.
I followed the documentations here to set my cronjob.
But as I mentioned, checking the log file shows that the script did not run.
Try running chmod 777 logfile.txt and then make sure that the logFile.txt permissions are
-rwxrwxrwx.
See if you still get the permission denied error.
After running chmod 777 logfile.txt I am able to run the script without sudo.
I'll try the cronjob and update you.
Cheers @GonzaloZiadi
I'm able to run the script now without sudo.
Unfortunately though the cronjob is not working.
The cron command I'm using is
cd /home/<myuser>/InstaPy && /usr/bin/python ./quickstart.py
Checking InstaPy/logs/logFile.txt shows no action at all.
The following is what appears in my syslog when the cronjob starts
Sep 29 01:00:01 XXXXX CRON[16247]: (<myuser>) CMD (cd /home/<myuser>/InstaPy && /usr/bin/python ./quickstart.py)
I've setup cron on Ubuntu with the following command
0 */3 * * * /home/ubuntu/InstaPy && python3.5 quickstart.py
It doesn't seem to be working. What's the best way to see if it's working? I'd like to be able to setup an email notification once it has started or completed or both...