I've written a shell script that does the following:   Retrieve mail from a POP3 account (using GetMail) Save a copy of that email to S3 (using AWS CLI) Email me the filesize of the email    The script runs fine manually, and technically runs from CRON, but it only seems to be sending the email. The getmail and S3 bits don't seem to run.  Everything I've read seems to hammer home the message that I need to be careful about relative paths and the like when using CRON, but I think I'm using absolute paths everywhere I need to be, so I'm stumped as to what the issue could be.  My Shell Script is here:  #!/bin/bash  # Run GetMail getmail -r /PATH/TO/EMAIL/getmail.email  # Save to S3 aws s3 cp /PATH/TO/SCRIPT/email-backup.mbox s3://XXXXXXXXXX/email-backup.mbox   # Send Confirmation Email  SUBJECT="EMAIL SUBJECT" EMAIL="My@EMAIL.COM"  # Get current filesize FILENAME=/PATH/TO/SCRIPT/email-backup.mbox FILESIZE=$(stat -c%s "$FILENAME")  # Email Content EMAILMESSAGE="/tmp/emailmessage.txt" echo "EMAIL BODY" &gt;$EMAILMESSAGE echo "" &gt;&gt;$EMAILMESSAGE echo "Current File Size: $FILESIZE bytes" &gt;&gt;$EMAILMESSAGE  # Send the Mail /bin/mail -s "$SUBJECT" "$EMAIL" &lt; $EMAILMESSAGE
589
This is a  about using cron &amp; crontab.   You have been directed here because the community is fairly sure that the answer to your question can be found below. If your question is not answered below then the answers will help you gather information that will help the community help you. This information should be edited into your original question.  The answer for 'Why is my crontab not working, and how can I troubleshoot it?' can be seen below.  This addresses the cron system with the crontab highlighted.
57173
to open send to folder in windows 7, we type  shell:sendto  and to open apps folder in windows 8, we type  shell:appsfolder  first of all, i would like to know what is this syntax known as (shell: something)  secondly, if anybody can tell me, please give the complete list of commands similar to this  thanks Gagan
62982
I have a cron job that runs every minute on an Ubuntu 12.04 box  $sudo crontab -e * * * * * mylogin /pathto/file.sh &gt; /log/filelog   If I run file.sh, the bash script does some stuff and echos out runs:  $ ./file.sh  runs   If I check the log of cron tab it shows that the job is running:  Jul 10 12:41:01 localhost CRON[1811]: (root) CMD (mylogin /pathto/file.sh &gt; /log/filelog) Jul 10 12:41:01 localhost CRON[1810]: (CRON) info (No MTA installed, discarding output) Jul 10 12:42:01 localhost CRON[1813]: (root) CMD (mylogin /pathto/file.sh &gt; /log/filelog)   However, the script is not running. It is not doing it's work and not echoing runs to /log/filelog.  $cat /log/filelog  #shows nothing   What other steps can I take to debug this problem?
36860
I am trying to run a bash script I have via cron, and I am getting the following error at the beginning of the execution:  tput: No value for $TERM and no -T specified   Here is what is in my crontab:  0 8 * * 1-5 cd /var/www/inv/ &amp;&amp; /var/www/inv/unitTest run all 2&gt;&amp;1| mail -r "user@example.com" -s "Daily Inventory Unit Test Results" user@example.com
59111
I want to run a script on all files with two specific extensions on a disk with a hierarchy of multiple nested folders.  My script works fine when I choose a folder further down the line with fewer subfolders but I'd like to run it on an entire archive with over a thousand folders.  The AppleScript takes forever to get all the files and then exits without returning anything and without executing the operations after getting the files.  No timeout message, no error message.  And the Finder becomes unresponsive (and remains stuck after the script exits).   set myFolder to choose folder with prompt "Choose a folder:"     tell application "Finder"         try             set eafFiles to (every file in entire contents of myFolder whose name ends with ".eaf") as alias list         on error             try                 set eafFiles to ((every file in entire contents of myFolder whose name ends with ".eaf") as alias) as list             on error                 set eafFiles to {}             end try         end try         try             set pfsxFiles to (every file in entire contents of myFolder whose name ends with ".pfsx") as alias list         on error             try                 set pfsxFiles to ((every file in entire contents of myFolder whose name ends with ".pfsx") as alias) as list             on error                 set pfsxFiles to {}             end try         end try         set myFiles to eafFiles &amp; pfsxFiles     end tell      repeat with CurrentFile in myFiles         set CurrentFile to CurrentFile as string          do shell script "perl /path/to/perl/script.pl " &amp; quoted form of CurrentFile     end repeat
54667
I just wanted to ask whether there is any command which would work on common shells (bash, dash, kornshell)? It is supposed to check if the line variable contains any part of the path.  if [[ $line =~ "$PWD"$ ]] ;then
26958
I would like to have cron output sent to an external email address, via a minimal SMTP client that sends via Gmail. I think I need this client to support TLS and /etc/aliases, and I would like configuration to be as simple as possible.
98935
I have a sample script (credit goes to ):  #!/bin/bash cat &lt;(cat /etc/lsb-release)   I save this script as somename.sh in my home directory.  Now, I try to open this file in three different ways:  sh somename.sh  bash somename.sh  ./somename.sh   So, I have two questions:   Why are the outputs for the above commands different though they are running the same script?   sh produces a Syntax error bash outputs the desired result ./ gives a Permission Denied error  Why is it necessary to give the script executable permission only when running the script using ./ and not necessary in the other cases?   Thanks in advance!  EDIT: The first part might be similar to the  linked one but, I did have a second question too.
68053
I created 3 daily cron jobs to run.  Below are the three that are placed in etc/cron.daily  rkhunter.sh  #!/bin/sh ( rkhunter --versioncheck rkhunter --update rkhunter --cronjob --report-warnings-only ) | mail -s 'rkhunter Daily Run (my server)' me@email.com   chkrootkit.sh  #!/bin/bash chkrootkit | mail -s "chkrootkit Daily Run (my server)" me@email.com   logwatch.sh  #!/bin/sh ( logwatch ) | mail -s 'logwatch Daily Log (my server)' me@email.com   I replaced me@email.com ofcourse with my email.  If I run this cronjob manually it works fine ./nameoffile.sh  But it doesn't run daily, what can be the cause or how can I check into this?
82155
This is my script:  #!/bin/bash hd='pwd' cd $hd   When I try to run it, it fails with:  line 3: cd: $'pwd\r\r': No such file or directory   What is going on?
15217
I finally set up a realistic backup schedule on my data through a shell script, which are handled by cron on tight intervals. Unfortunately, I keep getting empty emails each time the CRON has been executed and not only when things go wrong.   Is it possible to only make CRON send emails when something goes wrong, ie. my TAR doesn't execute as intended?  Here's how my crontab is setup for the moment;  0 */2 * * * /bin/backup.sh 2&gt;&amp;1 | mail -s "Backup status" email@example.com   Thanks a lot!
21713
I have Anacron set up to run a backup daily, weekly and monthly. The monthly seems okay, but the daily and the weekly are running roughly every half hour every day! Here is my /etc/anacrontab # /etc/anacrontab: configuration file for anacron                                                                                                                                                                            # See anacron(8) and anacrontab(5) for details.                                                                                                                                                                              SHELL=/bin/sh                                                                                                  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin                                              HOME=/root                                                                                                     LOGNAME=root                                                                                                                                                                                                             # These replace cron's entries                                                                                 1       5       cron.daily      run-parts --report /etc/cron.daily                                             7       10      cron.weekly     run-parts --report /etc/cron.weekly                                            @monthly        15      cron.monthly    run-parts --report /etc/cron.monthly                                                                                                                                           # PERIOD        DELAY   IDENTIFIER      COMMAND                                                                @daily  3       Rsnapshot_daily /root/scripts/rsnapshot_launcher.sh daily                                      @weekly 15      Rsnapshot_weekly        /root/scripts/rsnapshot_launcher.sh weekly                             @monthly        30      Rsnapshot_monthly       /root/scripts/rsnapshot_launcher.sh monthly  I've checked /var/spool/anacron/Rsnapshot_daily and it has todays date in it and was last updated less than 30 minutes ago. It's now 6pm and the daily Rsnapshot task has been run 11 times today and the weekly 10 times so far. What could be going on here? Thanks. (this is on Kubuntu 20.04 LTS)
96065
Running this script on: "Red Had Enterprise Linux Server release 5.11 (Tikanga)"  Mail is: version 8.1 6/6/93 (appears quite old).  Have tried various things and cannot seem to get this to work..  echo "Email message" | mail -a /home/user/checks/notprocessed.txt -a /home/user/checks/dirlist.txt -s "Subject" recipient@company.com /home/user/checks   Resulting message:     mail: invalid option -- a   mutt is not installed and I have limited access to this system as it is owned by the company I work for.  I could add in other components, but has to go through change management, and related processes.  uuencode is not available either.  Here is what I am using today and I am trying to add a second file to:  if grep 'Not Empty' /home/user/checks/notprocessed.txt    then    echo "files were found";     SUBJECT="NIGHTLY DIRECTORY LISTING OF FILES SENT TO VENDOR";    FROM="SENDER&lt;sender@company.com&gt;"    # EMAIL="JOHN DOE&lt;recipient@company.com&gt;"    EMAIL="MARY DOE&lt;recipient@company.com&gt;";    /bin/mail -s "$SUBJECT" "$EMAIL" -- -f "$FROM" &lt; /home/user/checks/notprocessed.txt /home/user/checks/dirlist.txt     exit -20 fi   And..  /home/user/checks/dirlist.txt is not attached or included as part of the e-mail.  I would like /home/user/checks/dirlist.txt to be actually an attachment  This actually does work - but includes the notprocessed.txt as the body of the email..  if grep 'Not Empty' /home/user/checks/notprocessed.txt    then    echo "files were found";     SUBJECT="NIGHTLY DIRECTORY LISTING OF FILES SENT TO VENDOR";    FROM="SENDER&lt;sender@company.com&gt;"    # EMAIL="JOHN DOE&lt;recipient@company.com&gt;"    EMAIL="MARY DOE&lt;recipient@company.com&gt;";    /bin/mail -s "$SUBJECT" "$EMAIL" -- -f "$FROM" &lt; /home/user/checks/notprocessed.txt     exit -20 fi
8430
I'm not well versed in shell scripting but I imagine this to be a painfully easy fix but its eluding me.  I need to copy the contents of a directory excluding a number of files. I have a command that works when I enter it into the terminal, but when its run in a shell script it fails with a syntax error or just doesn't work.   The command in question is:  cp -r path/to/!(dir1|dir2|dir3) destination   Any help would be greatly appreciated!
55862
I have a script that checks to see if port 4000 is open and listening, if it is return true, else start a service that also outputs a logfile. The script runs fine if I execute it as a user, but if I add it as a cron it doesn't run. I'm logged in as root, the script is owned by root, the script has executable permissions, and I am running crontab -e as root.   #!/bin/bash if lsof -Pi :4000 -sTCP:LISTEN -t &gt;/dev/null ; then     return 1 else     seoserver -p 4000 start &gt; /var/www/vhosts/domain.com/httpdocs/seoserver.log &amp; fi   And here is my cron  */5     *       *       *       *       /usr/bin/seoStart
6379
I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:  0 * * * * echo hello &gt;&gt; ~/cron-logs/hourly/test`date "+%d"`.log   Unfortunately I get this message when that runs:  /bin/sh: -c: line 0: unexpected EOF while looking for matching ``' /bin/sh: -c: line 1: syntax error: unexpected end of file   I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this?
40322
I have a crontab that looks like  0 0 * * * pg_dump DB_NAME &gt; /path/to/dumps/`date +%Y%m%d`.dmp   which works fine when I run it manually, but not when cron runs it. After digging through the logs, I see  Dec 12 00:00:01 localhost crond[17638]: (postgres) CMD (pg_dump DB_NAME &gt; /path/to/dumps/`date +)   It looks like a problem with percent signs, but the man page doesn't even contain the percent character at all, so I thought they were alright.