I am a newbie to raspberry pi's so please forgive my lack of knowledge.
A few years ago I was given a raspberry pi 3, I had it set up with a crontab file which ran some commands for me which have been running as they were set to do since then. I now find I need to add some more commands to thr file but I cannot find where it was saved to or if I named it something different to just 'crontab'?
When I run :-
pi@raspberrypi:~ $ sudo crontab -l
I get a blank crontab file
Also when I run :-
pi@raspberrypi:~ $ sudo crontab -e
I also get a blank crontab?
How do I find where the file is for my user (pi)?
================================================================
Thanks for the answers, I followed answer '0' and got:-
pi@raspberrypi:~ $ cat /etc/passwd | grep -v nologin
root:x:0:0:root:/root:/bin/bash
sync:x:4:65534:sync:/bin:/bin/sync
pi:x:1000:1000:,,,:/home/pi:/bin/bash
lightdm:x:109:114:Light Display Manager:/var/lib/lightdm:/bin/false
pi@raspberrypi:~ $
Now I know there is a cron job somewhere on my system as it runs executables which move files to my HDD otherwise my pi's memory would fill.
This is an old version that was done, but has been changed as the directories in it are now differently named:-
## Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
#### first jpg files #####
5 1 * * * find /CCTV/RearOfHouse/ -type f -mtime +7 -name '*.jpg' -execdir mv '{}' /CCTV/RearOfHouse/
5 2 * * * find /CCTV/FrontOfHouse/ -type f -mtime +7 -name '*.jpg' -execdir mv '{}' /CCTV/FrontOfHouse/
1 3* * * find /CCTV/FrontOfHouse/ -type f -mtime +70 -name '*.jpg' -execdir rm -- '{}'$
1 4 * * * find /CCTV/RearOfHouse/ -type f -mtime +70 -name '*.jpg' -execdir rm -- '{}'$
##1 5 * * * find /CCTV/ -type f -mtime +60 -name '*.jpg' -execdir rm -- '{}' \;
0 1 * * * /home/pi/CCTV/RearOfHouse/CreatejpgDirs.sh
10 1 * * * /home/pi/CCTV/FrontOfHouse/CreatejpgDirs.sh
#### now mp4 files #####
25 1 * * * find /CCTV/RearOfHouse/ -type f -mtime +7 -name '*.mp4' -execdir mv '{}' /CCTV/RearOfHouse/
25 2 * * * find /CCTV/FrontOfHouse/ -type f -mtime +7 -name '*.mp4' -execdir mv '{}' /CCTV/FrontOfHouse/
21 3 * * * find /CCTV/FrontOfHouse/ -type f -mtime +70 -name '*.mp4' -execdir rm -- '{$
21 4 * * * find /CCTV/RearOfHouse/ -type f -mtime +70 -name '*.mp4' -execdir rm -- '{}$
##21 5 * * * find /CCTV/ -type f -mtime +120 -name '*.mp4' -execdir rm -- '{}' \;
##21 6 * * * find /CCTV/ -type f -mtime +120 -name '*.mp4' -execdir rm -- '{}' \;
0 1 * * * /home/pi/CCTV/RearOfHouse/Createmp4Dirs.sh
10 1 * * * /home/pi/CCTV/FrontOfHouse/Createmp4Dirs.sh
so I don't know if the filename (for the cron job) has also been changed? So any clues as how to find it? Thanks WD
nb. here is my current structure:
pi@raspberrypi:~ $ ls
Desktop Downloads fdisk.save home jpgDirsRemovedR.txt jpgFilesRemovedR.txt mnt mp4DirsRemovedR.txt mp4FilesRemovedR.txt Pictures symlinks_all.txt Videos
Documents ExecFiles fluxion jpgDirsRemovedF.txt jpgFilesRemovedF.txt MagPi mp4DirsRemovedF.txt mp4FilesRemovedF.txt Music Public Templates
pi@raspberrypi:~ $ cd ExecFiles
(and this is the executables run by the cron file)
pi@raspberrypi:~/ExecFiles $ ls
CreatejpgDirsF.sh CreatejpgDirsF_WithDays.sh CreatejpgDirsR.sh CreatejpgDirsR_WithDays.sh Createmp4DirsF.sh Createmp4DirsF_WithDays.sh Createmp4DirsR.sh Createmp4DirsR_WithDays.sh
pi@raspberrypi:~/ExecFiles $
ls /var/spool/cron/crontabs
?grep -r "string" /home/pi
for all files under the user pi. But: 1) avoid asking further questions in the comments and 2) this probably won't help you here.