bash script,
#! /bin/bash
echo 'hi bash'
aa
python ~/fledgling/cron/test.py
echo 'after python script'
here aa is alias, which activates virtualenv
alias aa='cd /home/fledgling/projects/myblog/base'
python script,
import time
with open('~/fledgling/cron/%s.txt' % time.strftime("%Y_%m_%d__%H:%M:%S"), 'w') as f:
f.write('%s' % time.strftime("%Y_%m_%d__%H:%M:%S"))
I want to to run this python script for every one minute.
crontab,
* * * * * ~/fledgling/cron/test.sh >> ~/fledgling/cron/log.txt
contents of ~/fledgling/cron/log.txt ,
hi bash
after python script
Output of /var/log/syslog
✘ ✝ ~/fledgling/cron tail -f /var/log/syslog
Jun 24 13:46:01 mysys CRON[14697]: (mysys) CMD (~/fledgling/cron/test.sh >> ~/fledgling/cron/log.txt)
Jun 24 13:46:01 mysys CRON[14696]: (CRON) info (No MTA installed, discarding output)
Jun 24 13:47:01 mysys CRON[14736]: (mysys) CMD (~/fledgling/cron/test.sh >> ~/fledgling/cron/log.txt)
Jun 24 13:47:01 mysys CRON[14735]: (CRON) info (No MTA installed, discarding output)
Jun 24 13:48:01 mysys CRON[14747]: (mysys) CMD (~/fledgling/cron/test.sh >> ~/fledgling/cron/log.txt)
Jun 24 13:48:01 mysys CRON[14746]: (CRON) info (No MTA installed, discarding output)
Jun 24 13:48:11 mysys crontab[14769]: (mysys) BEGIN EDIT (mysys)
Jun 24 13:48:59 mysys crontab[14769]: (mysys) END EDIT (mysys)
Jun 24 13:49:01 mysys CRON[14794]: (mysys) CMD (~/fledgling/cron/test.sh >> ~/fledgling/cron/log.txt)
Jun 24 13:49:01 mysys CRON[14793]: (CRON) info (No MTA installed, discarding output)
Permissions,
-rw-rw-r-- 1 mysys mysys 476 Jun 24 13:57 log.txt
-rwxrw-r-- 1 mysys mysys 153 Jun 24 13:37 test.py
-rwxrwxr-x 1 mysys mysys 91 Jun 24 13:32 test.sh
What I want ? I want to create text file every minute.
What is my problem ? I can see in log that after every minute bash script is running with no error, then why python script is not getting executed or not creating any text file ?
#! /bin/bashshould be no space.~Where do you think that is going?