LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-27-2019, 03:48 AM   #1
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 22

Rep: Reputation: Disabled
Corntab to run a script on last working day of the month


how to make a Crontab to run a script on the last working day of the month.

Last edited by subir; 11-27-2019 at 04:05 AM.
 
Old 11-27-2019, 04:10 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by subir View Post
how to make a Crontab to run a script on the last working day of the month.
So what have you tried? You provide no useful information whatsoever as "last working day" can easily vary depending on how a company operates. A business that is open Saturday will have a different "last working day" from one that operates Monday -> Friday.

In any case, this kind of complex requirement should be handled inside your script rather than crontab.
 
Old 11-27-2019, 10:13 PM   #3
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 22

Original Poster
Rep: Reputation: Disabled
Why AT Command or crontab isn't running

Why AT Command or crontab isn't running in Linux? Whenever I tried to create its showing some "packages needed", display "sudo apt-get install <deb>"
So what to do to run AT or cronjob.

Last edited by subir; 11-27-2019 at 10:22 PM.
 
Old 11-28-2019, 01:10 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Something is wrong with your installation, I guess, but your description is not sufficient to help you.

Can you tell us the precise command that you enter, and the precise error message?

Also which distro you are using.
 
Old 12-03-2019, 03:05 AM   #5
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 22

Original Poster
Rep: Reputation: Disabled
Crontab to make directory in Desktop

why cronjob is not working for the below command.
my current location is "desktop"
touch a.sh created a.sh file
vi a.sh
mkdir abcd/ a.sh content command a.sh
crontab -e
* * * * * /subir/home/Desktop/a.sh
cronatab install.
but not make any directory after 1 min.
 
Old 12-03-2019, 03:54 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,840

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
crontab has no any idea about your current location. Crontab has its own very special environment.
 
1 members found this post helpful.
Old 12-03-2019, 11:39 AM   #7
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 22

Original Poster
Rep: Reputation: Disabled
Why crontab doesn't create file on Desktop

I tried command like
* * * * * mkdir new /home/subir/Desktop
But it create "new" directory in my home directory.
How to do that On desktop?
 
Old 12-03-2019, 11:56 AM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
See the man page: man mkdir for the correct syntax to create a directory.
Code:
SYNOPSIS
       mkdir [OPTION]... DIRECTORY...
Note that running mkdir from cron will only work the first time. mkdir will fail if the target directory already exists.
Why do you want to run that command from cron? And why do you want to run it every minute?
 
2 members found this post helpful.
Old 12-03-2019, 03:38 PM   #9
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
As above, think of cron as a user trying to do a task.
 
Old 12-06-2019, 10:33 PM   #10
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 22

Original Poster
Rep: Reputation: Disabled
Crontab not working at specific time

My command is Cat > a.sh

mkdir abc

Crontab -e

56 09 * * * /home/subir/Jarvis/a.sh

Doesn't create abc directory at that given time
 
Old 12-06-2019, 11:06 PM   #11
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by subir View Post
My command is Cat > a.sh

mkdir abc

Crontab -e

56 09 * * * /home/subir/Jarvis/a.sh

Doesn't create abc directory at that given time
Basically a duplicate. The answer has been provide in your other threads.

Reported.
 
Old 12-06-2019, 11:12 PM   #12
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Opening a new thread with the same question is contrary to the LQ Rules.

What about the answers here do you not understand?
 
1 members found this post helpful.
Old 12-06-2019, 11:16 PM   #13
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by scasey View Post
Note that running mkdir from cron will only work the first time. mkdir will fail if the target directory already exists.
Using the -p option will fix that. See the man page.
 
Old 12-06-2019, 11:46 PM   #14
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by ehartman View Post
Using the -p option will fix that. See the man page.
Point taken (ish), but with or without the -p option, re-executing the command from cron every minute is, IMO, pointless.

And, the -p option doesn't fix the fact that the OP is using incorrect syntax otherwise.

Nor does it fix the fact that the OP has asked the question in multiple threads three or four different ways but has provided no followup. They've asked the question, received an answer, and then asked the question again in a new thread. (sigh)
 
Old 12-07-2019, 04:25 AM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Yes but not necessarily in a clear way.

The command mkdir abc uses a relative path which is referenced to your current working directory. A absolute or full path is referenced to /. Since cron is not associated with the desktop or terminal window it does not have a current working directory. You should use the full desired path in your a.sh script.

mkdir /home/subir/Desktop/abc

Or whatever path you choose.

Last edited by michaelk; 12-07-2019 at 04:26 AM.
 
  


Reply

Tags
crontab, packages



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Get first day of last month and last day of last month in bash xowl Linux - Software 18 02-09-2017 09:49 AM
run schedule on the last day of month QWE123 Linux - Server 2 07-04-2015 10:56 PM
[SOLVED] rsnapshot - missing last month on a 3-month cycle. Fedora 15 steve_s Linux - Software 2 02-17-2012 04:51 AM
OpenOffice.org Calc formula to check if day is last day of the month win32sux Linux - Software 1 01-19-2009 12:38 PM
Starting day of month, month length chrisk5527 Programming 2 03-03-2004 04:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration