LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 04:48 AM   #1
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 11

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 05:05 AM.
 
Old 11-27-2019, 05:10 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,973

Rep: Reputation: 1232Reputation: 1232Reputation: 1232Reputation: 1232Reputation: 1232Reputation: 1232Reputation: 1232Reputation: 1232Reputation: 1232
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, 11:13 PM   #3
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 11

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 11:22 PM.
 
Old 11-28-2019, 02:10 AM   #4
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 3,709

Rep: Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010Reputation: 1010
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, 04:05 AM   #5
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 11

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, 04:54 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,290

Rep: Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207Reputation: 4207
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, 12:39 PM   #7
subir
LQ Newbie
 
Registered: Nov 2019
Posts: 11

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, 12:56 PM   #8
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,095

Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
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, 04:38 PM   #9
jefro
Moderator
 
Registered: Mar 2008
Posts: 19,360

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

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-07-2019, 12:06 AM   #11
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,095

Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
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-07-2019, 12:12 AM   #12
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,095

Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
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-07-2019, 12:16 AM   #13
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,037

Rep: Reputation: 589Reputation: 589Reputation: 589Reputation: 589Reputation: 589Reputation: 589
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-07-2019, 12:46 AM   #14
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,095

Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
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, 05:25 AM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,225

Rep: Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997Reputation: 2997
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 05:26 AM.
 
  


Reply

Tags
crontab, packages


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:49 AM
run schedule on the last day of month QWE123 Linux - Server 2 07-04-2015 11:56 PM
[SOLVED] rsnapshot - missing last month on a 3-month cycle. Fedora 15 steve_s Linux - Software 2 02-17-2012 05:51 AM
OpenOffice.org Calc formula to check if day is last day of the month win32sux Linux - Software 1 01-19-2009 01:38 PM
Starting day of month, month length chrisk5527 Programming 2 03-03-2004 05:03 PM

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

All times are GMT -5. The time now is 01:39 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration