Custom script gets renamed with dot and dashes appended

Don't miss a thing. Post your questions and discussion about other uncategorized NAS features here.
Post Reply
Kanti
First post
Posts: 1
Joined: Tue Mar 31, 2020 5:59 pm

Custom script gets renamed with dot and dashes appended

Post by Kanti » Tue Mar 31, 2020 6:38 pm

I have a TS-453Be running firmware version 4.4.1.1216.
I have a script named autosend.sh that looks for pdf files and mails them to a certain address.
I added this script to my crontab to run every morning at 04:04 am.

For some reason before cron can run it, some other mysterious process renames the script by appending a dot and two dashes: autosend.sh -> autosend.sh.--
It also removes the execute permissions and sets the permissions to -rw-r--r--.
By the time cron wants to run the script, it throws an error saying the script doesn't exist (because it is renamed by then).
Putting it in crontab with the dot and dashes, it gets renamed again (and permissions changed): autosend.sh.-- -> autosend.sh.--.--
First the script was located in the share made only for these pdf files.
I tried moving the script to /usr/bin/ and also tried removing the .sh (I thought maybe some process was searching for the .sh extension) but allas, it still appends .-- to the name and resets permissions.

Does anyone have any idea what could be happening here, or has an idea to help me find the cause of this?

This is what my crontab looks like

Code: Select all

# m h dom m dow cmd
0 2 * * * /sbin/qfstrim
0 3 * * 0 /etc/init.d/idmap.sh dump
0-59/20 3 * * * /sbin/adjust_time
0 3 * * * /sbin/vs_refresh
0 3 * * * /sbin/clean_reset_pwd
0-59/15 * * * * /etc/init.d/nss2_dusg.sh
30 7 * * * /sbin/clean_upload_file
0-59/10 * * * * /etc/init.d/storage_usage.sh
30 3 * * * /sbin/notice_log_tool -v -R
*/10 * * * * /sbin/config_cache_util 0
10 15 * * * /usr/bin/power_clean -c 2>/dev/null
0 1 * * * /etc/init.d/flush_memory.sh >/dev/null 2>&1
36 9,21 * * * /sbin/notify_update --nc 1>/dev/null 2>&1
30 3 * * * /sbin/storage_util --ironwolf_disk_health_test dev_id=00000003
30 3 * * * /sbin/storage_util --ironwolf_disk_health_test dev_id=00000004
44 * * * * /sbin/qddns_check 2>/dev/null
* * * * * /var/cache/netmgr/lock_timer.sh
0 4 * * * /etc/init.d/wsd.sh restart
0 0 * * * /usr/local/sbin/qsh nc.archive >/dev/null 2>&1
35 7 * * * /sbin/qsyncsrv_util -c  > /dev/null 2>/dev/null
0 0 * * * /sbin/qsyncsrv_tool --fix  > /dev/null 2>/dev/null
4 4 * * * bash usr/bin/autosend >> /share/FacturenScan/autosendlog.txt 2>>/share/FacturenScan/autosenderr.txt
0 4,16 * * * /sbin/hwclock -s
4 3 * * 3 /etc/init.d/backup_conf.sh
0 12 * * * /mnt/ext/opt/LicenseCenter/bin/qlicense_tool local_check
54 12 * * * /mnt/ext/opt/QcloudSSLCertificate/bin/ssl_agent_cli

User avatar
OneCD
Ask me anything
Posts: 7968
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Custom script gets renamed with dot and dashes appended

Post by OneCD » Wed Apr 01, 2020 3:28 am

Hi and welcome to the forum. :)
Kanti wrote:
Tue Mar 31, 2020 6:38 pm
Does anyone have any idea what could be happening here, or has an idea to help me find the cause of this?
Is Malware Remover installed? I wonder if it's messing with your crontab entry? :?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

laengu
Starting out
Posts: 12
Joined: Fri Jun 12, 2015 9:12 pm

Re: Custom script gets renamed with dot and dashes appended

Post by laengu » Sun Apr 05, 2020 5:59 pm

Hi
I have the same problem, a bash script in the same folder as the files are. The folder is a subfolder in a share.
QTS 4.4.1.1216 on a TVS-671

I suspected Backup Station behind that, but I disabled the backup running in that share.
What I'm testing now is, if I copy the script, give it a new name and alternate the crontab to the new name if both files get renamed.
It does not happen if I run the script manually, so it must be something running from QTS.

laengu
Starting out
Posts: 12
Joined: Fri Jun 12, 2015 9:12 pm

Re: Custom script gets renamed with dot and dashes appended

Post by laengu » Tue Apr 07, 2020 7:10 pm

So I did some more testing.
It is not Backup Station, it's cron who renames the script.
Why though?!

laengu
Starting out
Posts: 12
Joined: Fri Jun 12, 2015 9:12 pm

Re: Custom script gets renamed with dot and dashes appended

Post by laengu » Mon Apr 13, 2020 5:44 pm

Finally found what is causing the scripts to get renamed.
It's the following part: >/dev/null 2>&1

If my crontab runs like this, the bash script gets renamed to "script.sh.--":
00 9 * * * /share/CACHE/script.sh >/dev/null 2>&1

If I run crontab without the null output, the script is executed without getting renamed:
00 9 * * * /share/CACHE/scrip.sh

tgsbn
Getting the hang of things
Posts: 75
Joined: Sun Nov 10, 2019 9:40 pm

Re: Custom script gets renamed with dot and dashes appended

Post by tgsbn » Tue Apr 14, 2020 2:52 am

I vote for Malware Remover as prime suspect.

TheBrad
Starting out
Posts: 41
Joined: Sun Feb 14, 2010 8:14 pm

Re: Custom script gets renamed with dot and dashes appended

Post by TheBrad » Fri May 22, 2020 2:14 pm

+1. Funnily enough, only the last two custom shell scripts I added to my crontab are renamed to "*.sh.--" every morning I look at the files, a backup script I call from cron since years remains unchanged and is functional. What makes the difference? I've changed the crontab to the run the scripts with or without null option, but that is not the culprit.

I disabled the automatic check of Malware Remover today to see whether that changes something.

I really would like to know, which service renames the custom .sh files, according to which criteria and for whatever reason.
TS 669L, TS251+ (v4.3.4)

cembasu
New here
Posts: 9
Joined: Fri Nov 20, 2015 12:22 pm

Re: Custom script gets renamed with dot and dashes appended

Post by cembasu » Wed Sep 02, 2020 7:02 am

Use `stat` on the file to see last accessed/changed and correlate to other tasks running from crontab. If `stat` is not available (through Entware packages) but if that is not available, you can use `ls -lu {file}` (last accessed) and `ls -lc {file}` (last changed) to obtain the same info and try to correlate.

Post Reply

Return to “Miscellaneous”