Score:0

Replace crontab programmatically

tr flag

Usually this works directly in terminal

crontab /somedirectory/filetobecopied.txt

this copies the filetobecopied.txt to crontab -e

but if i used this inside a subprocess or an os command it does not work though it does not throw an error.

subprocess.run('crontab /somedirectory/filetobecopied.txt',shell = True,capture_output = True)
#or
subprocess.call('crontab /somedirectory/filetobecopied.txt',shell = True,capture_output = True)
#or
os.system('crontab /somedirectory/filetobecopied.txt')
nobody avatar
in flag
Which user is running you script? Is it possible, that crontab works but saves the file for another user. Do you run it with `sudo`? Use `crontab -u <username>`. If you do not get any error, crontab is probably executed, but nevertheless I would recommend to use the whole path `/usr/bin/crontab`. You never know what will be in your `$PATH`.
Weeway avatar
tr flag
Yes of course! Thanks for reminding. Cheers
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.