You are not logged in.

#1 2018-09-18 20:41:46

Moltke
Member
Registered: 2016-07-12
Posts: 59

(SOLVED) Cronjob for a script

Hi everyone! Hope you're all having a nice life! smile

I wrote a very simple script to copy files from one dir into another one, I want to create a cronjob so it runs once a week - on Sundays - but I'm not sure whether if it's correct or not. Can you take a look and tell me so?
this is the cronjob:

0 1  * 1-12 SUN /home/myusername/dir/cp.sh 
or

0 1  * 1-12 SUN /bin/bash /home/myusername/dir/cp.sh

I've read quite a few posts from here as well as over the web but I'm still confused. Thanks in advance for your answers.

Last edited by Moltke (2018-09-18 23:52:08)


Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!

Offline

#2 2018-09-18 20:49:37

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: (SOLVED) Cronjob for a script

Looks okay I guess, but why not wildcard the 1-12 months too?

Anyway, you don't need /bin/bash if the script itself is executable and has a #!/bin/bash shebang.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#3 2018-09-18 21:03:42

Moltke
Member
Registered: 2016-07-12
Posts: 59

Re: (SOLVED) Cronjob for a script

Eschwartz wrote:

Looks okay I guess, but why not wildcard the 1-12 months too?

Anyway, you don't need /bin/bash if the script itself is executable and has a #!/bin/bash shebang.

So, just to be perfectly clear, would this 0 1  * * SUN /home/myusername/dir/cp.sh be ok and would have the same effect as 0 1  * 1-12 SUN /home/myusername/dir/cp.sh? And yes, you're right. Script has a #!/bin/bash shebang and it's exceutable.

Thanks for your answer!


Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!

Offline

#4 2018-09-18 22:47:32

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,238
Website

Re: (SOLVED) Cronjob for a script

If you use `crontab -e` to edit your cron files, crond will syntax check the file before saving it.... Thereby avoiding you having to wait for the community to tell you.

Offline

#5 2018-09-18 23:15:07

Moltke
Member
Registered: 2016-07-12
Posts: 59

Re: (SOLVED) Cronjob for a script

fukawi2 wrote:

If you use `crontab -e` to edit your cron files, crond will syntax check the file before saving it.... Thereby avoiding you having to wait for the community to tell you.

Good to know! I've already succesfully created the cronjob smile It's a very simple task. I used this site https://crontab.guru/ which I read was useful when it comes to using cron and indeed it is. Thanks for your answer!


Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!

Offline

Board footer

Powered by FluxBB